From 7b21b8f4e922d061e74f1d181b5e17381f14ce89 Mon Sep 17 00:00:00 2001 From: Robert Lipe Date: Mon, 13 Nov 2017 03:52:18 -0600 Subject: [PATCH] The final (?) piece for presubmit jooy.. --- osm.cc | 39 +- ozi.cc | 2 + pcx.cc | 10 +- pocketfms_bc.cc | 4 +- pocketfms_fp.cc | 10 +- pocketfms_wp.cc | 2 + polygon.cc | 10 +- position.cc | 16 +- psitrex.cc | 8 +- radius.cc | 20 +- random.cc | 12 +- raymarine.cc | 76 +- reverse_route.cc | 6 +- saroute.cc | 14 +- sbn.cc | 12 +- sbp.cc | 12 +- shape.cc | 10 +- skyforce.cc | 2 + skytraq.cc | 2936 +++++++++++++++++++++++----------------------- smplrout.cc | 16 +- sort.cc | 12 +- stackfilter.cc | 26 +- stmsdf.cc | 10 +- stmwpp.cc | 6 +- subrip.cc | 10 +- tef_xml.cc | 20 +- teletype.cc | 2 + text.cc | 14 +- tiger.cc | 28 +- tmpro.cc | 2 + tomtom.cc | 2 + tpg.cc | 5 +- tpo.cc | 6 +- trackfilter.cc | 68 +- transform.cc | 24 +- unicsv.cc | 16 +- v900.cc | 3 +- validate.cc | 10 +- vcf.cc | 4 +- vidaone.cc | 4 +- vitosmt.cc | 2 + vitovtt.cc | 2 + vpl.cc | 4 +- waypt.cc | 8 +- wbt-200.cc | 6 +- wfff_xml.cc | 19 +- wintec_tes.cc | 2 + xcsv.cc | 19 +- xol.cc | 24 +- yahoo.cc | 14 +- 50 files changed, 1836 insertions(+), 1753 deletions(-) diff --git a/osm.cc b/osm.cc index a0abe232b..25775a2c3 100644 --- a/osm.cc +++ b/osm.cc @@ -29,9 +29,9 @@ static char* opt_tag, *opt_tagnd, *created_by; static arglist_t osm_args[] = { - { "tag", &opt_tag, "Write additional way tag key/value pairs", NULL, ARGTYPE_STRING, ARG_NOMINMAX }, - { "tagnd", &opt_tagnd, "Write additional node tag key/value pairs", NULL, ARGTYPE_STRING, ARG_NOMINMAX }, - { "created_by", &created_by, "Use this value as custom created_by value","GPSBabel", ARGTYPE_STRING, ARG_NOMINMAX }, + { "tag", &opt_tag, "Write additional way tag key/value pairs", NULL, ARGTYPE_STRING, ARG_NOMINMAX, nullptr}, + { "tagnd", &opt_tagnd, "Write additional node tag key/value pairs", NULL, ARGTYPE_STRING, ARG_NOMINMAX, nullptr }, + { "created_by", &created_by, "Use this value as custom created_by value","GPSBabel", ARGTYPE_STRING, ARG_NOMINMAX, nullptr }, ARG_TERMINATOR }; @@ -408,7 +408,7 @@ static osm_icon_mapping_t osm_icon_mappings[] = { /*-----------------------------------------------------------------------------*/ static void -osm_features_init(void) +osm_features_init() { int i; @@ -477,7 +477,7 @@ osm_strip_html(const QString& str) static void -osm_node_end(xg_string args, const QXmlStreamAttributes*) +osm_node_end(xg_string, const QXmlStreamAttributes*) { if (wpt) { if (wpt->wpt_flags.fmt_use) { @@ -491,7 +491,7 @@ osm_node_end(xg_string args, const QXmlStreamAttributes*) static void -osm_node(xg_string args, const QXmlStreamAttributes* attrv) +osm_node(xg_string, const QXmlStreamAttributes* attrv) { wpt = new Waypoint; @@ -523,7 +523,7 @@ osm_node(xg_string args, const QXmlStreamAttributes* attrv) static void -osm_node_tag(xg_string args, const QXmlStreamAttributes* attrv) +osm_node_tag(xg_string, const QXmlStreamAttributes* attrv) { QString key, value; QString str; @@ -578,7 +578,7 @@ osm_node_tag(xg_string args, const QXmlStreamAttributes* attrv) static void -osm_way(xg_string args, const QXmlStreamAttributes* attrv) +osm_way(xg_string, const QXmlStreamAttributes* attrv) { rte = route_head_alloc(); // create a wpt to represent the route center if it has a center tag @@ -589,7 +589,7 @@ osm_way(xg_string args, const QXmlStreamAttributes* attrv) } static void -osm_way_nd(xg_string args, const QXmlStreamAttributes* attrv) +osm_way_nd(xg_string, const QXmlStreamAttributes* attrv) { if (attrv->hasAttribute("ref")) { QString atstr = attrv->value("ref").toString(); @@ -607,7 +607,7 @@ osm_way_nd(xg_string args, const QXmlStreamAttributes* attrv) } static void -osm_way_tag(xg_string args, const QXmlStreamAttributes* attrv) +osm_way_tag(xg_string, const QXmlStreamAttributes* attrv) { QString key, value; QString str; @@ -645,7 +645,7 @@ osm_way_tag(xg_string args, const QXmlStreamAttributes* attrv) } static void -osm_way_center(xg_string args, const QXmlStreamAttributes* attrv) +osm_way_center(xg_string, const QXmlStreamAttributes* attrv) { wpt->wpt_flags.fmt_use = 1; @@ -658,7 +658,7 @@ osm_way_center(xg_string args, const QXmlStreamAttributes* attrv) } static void -osm_way_end(xg_string args, const QXmlStreamAttributes*) +osm_way_end(xg_string, const QXmlStreamAttributes*) { if (rte) { route_add_head(rte); @@ -690,13 +690,13 @@ osm_rd_init(const QString& fname) } static void -osm_read(void) +osm_read() { xml_read(); } static void -osm_rd_deinit(void) +osm_rd_deinit() { xml_deinit(); waypoints.clear(); @@ -707,7 +707,7 @@ osm_rd_deinit(void) /*-----------------------------------------------------------------------------*/ static void -osm_init_icons(void) +osm_init_icons() { int i; @@ -937,7 +937,7 @@ osm_wr_init(const QString& fname) } static void -osm_write(void) +osm_write() { gbfprintf(fout, "\n"); gbfprintf(fout, "altitude); } -static void data_write(void) { +static void data_write() { gbfprintf(file_out, "H SOFTWARE NAME & VERSION\n" "I PCX5 2.09\n" @@ -410,4 +410,6 @@ ff_vecs_t pcx_vecs = { ff_type_file, FF_CAP_RW_ALL, rd_init, wr_init, rd_deinit, wr_deinit, data_read, data_write, NULL, pcx_args, CET_CHARSET_ASCII, 1 /* CET-REVIEW */ + , NULL_POS_OPS, + nullptr }; diff --git a/pocketfms_bc.cc b/pocketfms_bc.cc index c263593cd..897070941 100644 --- a/pocketfms_bc.cc +++ b/pocketfms_bc.cc @@ -121,7 +121,7 @@ read_tracks(void) } static void -route_head_noop(const route_head* wp) +route_head_noop(const route_head*) { } @@ -190,4 +190,6 @@ ff_vecs_t pocketfms_bc_vecs = { NULL, NULL, CET_CHARSET_ASCII, 0 /* CET-REVIEW */ + , NULL_POS_OPS, + nullptr }; diff --git a/pocketfms_fp.cc b/pocketfms_fp.cc index a31fe3b37..da0ecb857 100644 --- a/pocketfms_fp.cc +++ b/pocketfms_fp.cc @@ -80,12 +80,12 @@ rd_deinit(void) } static void -wr_init(const QString& fname) +wr_init(const QString&) { fatal("Writing file of type %s is not supported\n", MYNAME); } -void wpt_s(xg_string args, const QXmlStreamAttributes*) +void wpt_s(xg_string, const QXmlStreamAttributes*) { if (isFirst == 1) { wpt_from = new Waypoint; @@ -96,7 +96,7 @@ void wpt_s(xg_string args, const QXmlStreamAttributes*) wpt_to = new Waypoint; } -void wpt_e(xg_string args, const QXmlStreamAttributes*) +void wpt_e(xg_string, const QXmlStreamAttributes*) { if (isFirst == 1) { route_add_wpt(route, wpt_from); @@ -161,7 +161,7 @@ void wpt_to_elev(xg_string args, const QXmlStreamAttributes*) dest_altitude = FEET_TO_METERS(args.toDouble()); } -void wpt_altitude(xg_string args, const QXmlStreamAttributes* attrv) +void wpt_altitude(xg_string, const QXmlStreamAttributes* attrv) { int isFeet = 0; @@ -192,4 +192,6 @@ ff_vecs_t pocketfms_fp_vecs = { NULL, NULL, CET_CHARSET_ASCII, 0 /* CET-REVIEW */ + , NULL_POS_OPS, + nullptr }; diff --git a/pocketfms_wp.cc b/pocketfms_wp.cc index 7a730ae12..bb6365212 100644 --- a/pocketfms_wp.cc +++ b/pocketfms_wp.cc @@ -151,4 +151,6 @@ ff_vecs_t pocketfms_wp_vecs = { NULL, NULL, CET_CHARSET_ASCII, 0 /* CET-REVIEW */ + , NULL_POS_OPS, + nullptr }; diff --git a/polygon.cc b/polygon.cc index bb8f73bb9..d043229e8 100644 --- a/polygon.cc +++ b/polygon.cc @@ -112,11 +112,11 @@ static arglist_t polygon_args[] = { { "file", &polyfileopt, "File containing vertices of polygon", - NULL, ARGTYPE_FILE | ARGTYPE_REQUIRED, ARG_NOMINMAX + NULL, ARGTYPE_FILE | ARGTYPE_REQUIRED, ARG_NOMINMAX, nullptr }, { "exclude", &exclopt, "Exclude points inside the polygon", - NULL, ARGTYPE_BOOL, ARG_NOMINMAX + NULL, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr }, ARG_TERMINATOR }; @@ -234,7 +234,7 @@ static void polytest(double lat1, double lon1, #define BADVAL 999999 void -polygon_process(void) +polygon_process() { queue* elem, * tmp; Waypoint* waypointp; @@ -341,13 +341,13 @@ polygon_process(void) } void -polygon_init(const char* args) +polygon_init(const char*) { /* do nothing */ } void -polygon_deinit(void) +polygon_deinit() { /* do nothing */ } diff --git a/position.cc b/position.cc index 2b06c5db3..48b6f296b 100644 --- a/position.cc +++ b/position.cc @@ -48,16 +48,16 @@ static arglist_t position_args[] = { { "distance", &distopt, "Maximum positional distance", - NULL, ARGTYPE_FLOAT | ARGTYPE_REQUIRED, ARG_NOMINMAX + NULL, ARGTYPE_FLOAT | ARGTYPE_REQUIRED, ARG_NOMINMAX, nullptr }, { "all", &purge_duplicates, "Suppress all points close to other points", - NULL, ARGTYPE_BOOL, ARG_NOMINMAX + NULL, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr }, { "time", &timeopt, "Maximum time in seconds beetween two points", - NULL, ARGTYPE_FLOAT | ARGTYPE_REQUIRED, ARG_NOMINMAX + NULL, ARGTYPE_FLOAT | ARGTYPE_REQUIRED, ARG_NOMINMAX, nullptr }, ARG_TERMINATOR }; @@ -179,16 +179,16 @@ position_process_route(const route_head* rh) } static void -position_noop_w(const Waypoint* w) +position_noop_w(const Waypoint*) { } static void -position_noop_t(const route_head* h) +position_noop_t(const route_head*) { } -void position_process(void) +void position_process() { int i = waypt_count(); @@ -201,7 +201,7 @@ void position_process(void) } void -position_init(const char* args) +position_init(const char*) { char* fm; @@ -225,7 +225,7 @@ position_init(const char* args) } void -position_deinit(void) +position_deinit() { } diff --git a/psitrex.cc b/psitrex.cc index 02cd7f258..6961359da 100644 --- a/psitrex.cc +++ b/psitrex.cc @@ -293,7 +293,7 @@ psit_isKnownToken(char* buf) * MRCB */ static void -psit_waypoint_r(gbfile* psit_file, Waypoint** wpt) +psit_waypoint_r(gbfile* psit_file, Waypoint**) { int garmin_icon_num; @@ -509,7 +509,7 @@ psit_routehdr_w_wrapper(const route_head* rte) * MRCB */ static void -psit_track_r(gbfile* psit_file, route_head** trk) +psit_track_r(gbfile* psit_file, route_head**) { char trkname[256]; unsigned int trk_num; @@ -748,7 +748,7 @@ psit_read(void) } static void -psit_noop(const route_head* wp) +psit_noop(const route_head*) { /* no-op */ } @@ -798,4 +798,6 @@ ff_vecs_t psit_vecs = { NULL, psit_args, CET_CHARSET_ASCII, 0 /* CET-REVIEW */ + , NULL_POS_OPS, + nullptr }; diff --git a/radius.cc b/radius.cc index c80cf52d0..19e80bd0a 100644 --- a/radius.cc +++ b/radius.cc @@ -50,31 +50,31 @@ static arglist_t radius_args[] = { { "lat", &latopt, "Latitude for center point (D.DDDDD)", - NULL, ARGTYPE_FLOAT | ARGTYPE_REQUIRED, ARG_NOMINMAX + NULL, ARGTYPE_FLOAT | ARGTYPE_REQUIRED, ARG_NOMINMAX, nullptr }, { "lon", &lonopt, "Longitude for center point (D.DDDDD)", - NULL, ARGTYPE_FLOAT | ARGTYPE_REQUIRED, ARG_NOMINMAX + NULL, ARGTYPE_FLOAT | ARGTYPE_REQUIRED, ARG_NOMINMAX, nullptr }, { "distance", &distopt, "Maximum distance from center", - NULL, ARGTYPE_FLOAT | ARGTYPE_REQUIRED, ARG_NOMINMAX + NULL, ARGTYPE_FLOAT | ARGTYPE_REQUIRED, ARG_NOMINMAX, nullptr }, { "exclude", &exclopt, "Exclude points close to center", - NULL, ARGTYPE_BOOL, ARG_NOMINMAX + NULL, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr }, { "nosort", &nosort, "Inhibit sort by distance to center", - NULL, ARGTYPE_BOOL, ARG_NOMINMAX + NULL, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr }, { "maxcount", &maxctarg,"Output no more than this number of points", - NULL, ARGTYPE_INT, "1", NULL + NULL, ARGTYPE_INT, "1", NULL, nullptr }, { "asroute", &routename,"Put resulting waypoints in route of this name", - NULL, ARGTYPE_STRING, NULL, NULL + NULL, ARGTYPE_STRING, NULL, NULL, nullptr }, ARG_TERMINATOR }; @@ -109,7 +109,7 @@ dist_comp(const void* a, const void* b) } void -radius_process(void) +radius_process() { #if !NEWQ queue* elem, * tmp; @@ -203,7 +203,7 @@ radius_process(void) } void -radius_init(const char* args) +radius_init(const char*) { char* fm; @@ -235,7 +235,7 @@ radius_init(const char* args) } void -radius_deinit(void) +radius_deinit() { if (home_pos) { xfree(home_pos); diff --git a/random.cc b/random.cc index ea0968716..611f51cd3 100644 --- a/random.cc +++ b/random.cc @@ -31,11 +31,11 @@ static char* opt_points, *opt_seed; static arglist_t random_args[] = { { "points", &opt_points, "Generate # points", NULL, - ARGTYPE_INT, "1", NULL + ARGTYPE_INT, "1", NULL, nullptr }, { "seed", &opt_seed, "Starting seed of the internal number generator", NULL, - ARGTYPE_INT, "1", NULL + ARGTYPE_INT, "1", NULL, nullptr }, ARG_TERMINATOR }; @@ -97,17 +97,17 @@ rand_qstr(const int maxlen, const char* fmt) } static void -random_rd_init(const QString& fname) +random_rd_init(const QString&) { } static void -random_rd_deinit(void) +random_rd_deinit() { } static void -random_read(void) +random_read() { #define RND(a) (rand_int(a) > 0) @@ -268,4 +268,6 @@ ff_vecs_t random_vecs = { NULL, /* exit */ random_args, CET_CHARSET_ASCII, 1 /* fixed */ + , NULL_POS_OPS, + nullptr }; diff --git a/raymarine.cc b/raymarine.cc index ebef78375..fa021ff55 100644 --- a/raymarine.cc +++ b/raymarine.cc @@ -66,7 +66,7 @@ static char* opt_location; static arglist_t raymarine_args[] = { - { "location", &opt_location, "Default location", "My Waypoints", ARGTYPE_STRING, ARG_NOMINMAX }, + { "location", &opt_location, "Default location", "My Waypoints", ARGTYPE_STRING, ARG_NOMINMAX , nullptr}, ARG_TERMINATOR }; @@ -85,54 +85,54 @@ typedef struct { } raymarine_symbol_mapping_t; static raymarine_symbol_mapping_t raymarine_symbols[] = { - { /* 0 */ "Unknown Symbol 0" }, - { /* 1 */ "Unknown Symbol 1" }, - { /* 2 */ "Unknown Symbol 2" }, - { /* 3 */ "Red Square" }, - { /* 4 */ "Big Fish" }, - { /* 5 */ "Anchor" }, + { /* 0 */ "Unknown Symbol 0", nullptr }, + { /* 1 */ "Unknown Symbol 1", nullptr }, + { /* 2 */ "Unknown Symbol 2", nullptr }, + { /* 3 */ "Red Square", nullptr }, + { /* 4 */ "Big Fish", nullptr }, + { /* 5 */ "Anchor", nullptr }, { /* 6 */ "Smiley", "Contact, Smiley" }, - { /* 7 */ "Sad" }, + { /* 7 */ "Sad", nullptr }, { /* 8 */ "Red Button", "Navaid, Red" }, - { /* 9 */ "Sailfish" }, + { /* 9 */ "Sailfish", nullptr }, { /* 10 */ "Danger", "Skull and Crossbones" }, - { /* 11 */ "Attention" }, - { /* 12 */ "Black Square" }, + { /* 11 */ "Attention", nullptr }, + { /* 12 */ "Black Square", nullptr }, { /* 13 */ "Intl. Dive Flag", "Diver Down Flag 2" }, { /* 14 */ "Vessel", "Marina" }, - { /* 15 */ "Lobster" }, + { /* 15 */ "Lobster", nullptr }, { /* 16 */ "Buoy", "Buoy, White" }, - { /* 17 */ "Exclamation" }, - { /* 18 */ "Red X" }, - { /* 19 */ "Check Mark" }, - { /* 20 */ "Black Plus" }, - { /* 21 */ "Black Cross" }, - { /* 22 */ "MOB" }, - { /* 23 */ "Billfish" }, - { /* 24 */ "Bottom Mark" }, + { /* 17 */ "Exclamation", nullptr }, + { /* 18 */ "Red X", nullptr }, + { /* 19 */ "Check Mark", nullptr }, + { /* 20 */ "Black Plus", nullptr }, + { /* 21 */ "Black Cross", nullptr }, + { /* 22 */ "MOB", nullptr }, + { /* 23 */ "Billfish", nullptr }, + { /* 24 */ "Bottom Mark", nullptr }, { /* 25 */ "Circle", "Circle, Red" }, { /* 26 */ "Diamond", "Block, Red" }, { /* 27 */ "Diamond Quarters", "Diamond, Red" }, { /* 28 */ "U.S. Dive Flag", "Diver Down Flag 1" }, - { /* 29 */ "Dolphin" }, - { /* 30 */ "Few Fish" }, - { /* 31 */ "Multiple Fish" }, - { /* 32 */ "Many Fish" }, - { /* 33 */ "Single Fish" }, - { /* 34 */ "Small Fish" }, - { /* 35 */ "Marker" }, + { /* 29 */ "Dolphin", nullptr }, + { /* 30 */ "Few Fish", nullptr }, + { /* 31 */ "Multiple Fish", nullptr }, + { /* 32 */ "Many Fish", nullptr }, + { /* 33 */ "Single Fish", nullptr }, + { /* 34 */ "Small Fish", nullptr }, + { /* 35 */ "Marker", nullptr }, { /* 36 */ "Cocktails", "Bar" }, - { /* 37 */ "Red Box Marker" }, - { /* 38 */ "Reef" }, - { /* 39 */ "Rocks" }, - { /* 40 */ "Fish School" }, + { /* 37 */ "Red Box Marker", nullptr }, + { /* 38 */ "Reef", nullptr }, + { /* 39 */ "Rocks", nullptr }, + { /* 40 */ "Fish School", nullptr }, { /* 41 */ "Seaweed", "Weed Bed" }, - { /* 42 */ "Shark" }, - { /* 43 */ "Sportfisher" }, + { /* 42 */ "Shark", nullptr }, + { /* 43 */ "Sportfisher", nullptr }, { /* 44 */ "Swimmer", "Swimming Area" }, - { /* 45 */ "Top Mark" }, - { /* 46 */ "Trawler" }, - { /* 47 */ "Tree" }, + { /* 45 */ "Top Mark", nullptr }, + { /* 46 */ "Trawler", nullptr }, + { /* 47 */ "Tree", nullptr }, { /* 48 */ "Triangle", "Triangle, Red" }, { /* 49 */ "Wreck", "Shipwreck" } }; @@ -285,7 +285,7 @@ same_points(const Waypoint* A, const Waypoint* B) } static void -register_waypt(const Waypoint* ref, const char is_rtept) +register_waypt(const Waypoint* ref, const char) { int i; Waypoint* wpt = (Waypoint*) ref; @@ -528,4 +528,6 @@ ff_vecs_t raymarine_vecs = { NULL, raymarine_args, CET_CHARSET_ASCII, 0 /* should we force this to 1 ? */ + , NULL_POS_OPS, + nullptr }; diff --git a/reverse_route.cc b/reverse_route.cc index 2f78601d9..c072caf84 100644 --- a/reverse_route.cc +++ b/reverse_route.cc @@ -56,14 +56,14 @@ reverse_route_head(const route_head* rte) } void -reverse_route_process(void) +reverse_route_process() { track_disp_all(reverse_route_head, NULL, reverse_route_wpt); route_disp_all(reverse_route_head, NULL, NULL); } void -reverse_route_init(const char* args) +reverse_route_init(const char*) { switch (global_opts.objective) { case rtedata: @@ -77,7 +77,7 @@ reverse_route_init(const char* args) } void -reverse_route_deinit(void) +reverse_route_deinit() { /* do nothing */ } diff --git a/saroute.cc b/saroute.cc index d2cfe5b1c..e8a4d1012 100644 --- a/saroute.cc +++ b/saroute.cc @@ -40,23 +40,23 @@ arglist_t saroute_args[] = { { "turns_important", &turns_important, "Keep turns if simplify filter is used", - NULL, ARGTYPE_BOOL, ARG_NOMINMAX + NULL, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr }, { "turns_only", &turns_only, "Only read turns; skip all other points", - NULL, ARGTYPE_BOOL, ARG_NOMINMAX + NULL, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr }, { "split", &split, "Split into multiple routes at turns", - NULL, ARGTYPE_BOOL, ARG_NOMINMAX + NULL, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr }, { "controls", &controls, "Read control points as waypoint/route/none", - "none", ARGTYPE_STRING, ARG_NOMINMAX + "none", ARGTYPE_STRING, ARG_NOMINMAX, nullptr }, { "times", ×ynth, "Synthesize track times", - NULL, ARGTYPE_BOOL, ARG_NOMINMAX + NULL, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr }, ARG_TERMINATOR }; @@ -464,7 +464,7 @@ my_read(void) } static void -wr_init(const QString& fname) +wr_init(const QString&) { fatal(MYNAME ":Not enough information is known about this format to write it.\n"); } @@ -481,4 +481,6 @@ ff_vecs_t saroute_vecs = { NULL, saroute_args, CET_CHARSET_UTF8, 1 /* do nothing | CET-REVIEW */ + , NULL_POS_OPS, + nullptr }; diff --git a/sbn.cc b/sbn.cc index 45fecec0a..f70195c28 100644 --- a/sbn.cc +++ b/sbn.cc @@ -137,6 +137,8 @@ hdrcpy(char* dest, const char* src, size_t max_len) int locosys_decode_file_id(char* header, size_t len) { + Q_UNUSED(header); + Q_UNUSED(len); #ifdef LOCOSYS_PARSE_FILE_ID /* * MID_FILE_ID(0xfd) contains the following payload : @@ -169,7 +171,7 @@ locosys_decode_file_id(char* header, size_t len) } static void -read_sbn_header(route_head* track) +read_sbn_header(route_head*) { char header[QRY_INFORMATION_LEN]; size_t len; @@ -284,13 +286,13 @@ sbn_rd_init(const QString& fname) } static void -sbn_rd_deinit(void) +sbn_rd_deinit() { gbfclose(file_handle); } static void -sbn_read(void) +sbn_read() { if (global_opts.masked_objective & TRKDATAMASK) { route_head* track; @@ -305,7 +307,7 @@ sbn_read(void) } static void -sbn_exit(void) +sbn_exit() { } @@ -329,5 +331,7 @@ ff_vecs_t sbn_vecs = { /* Characters are always encoded in ASCII. Even if the unit is set * to Chinese language, only ASCII characters can be entered. */ CET_CHARSET_ASCII, 0 + , NULL_POS_OPS, + nullptr }; /**********************************************************************/ diff --git a/sbp.cc b/sbp.cc index c940b7144..b0143e429 100644 --- a/sbp.cc +++ b/sbp.cc @@ -43,13 +43,13 @@ sbp_rd_init(const QString& fname) } static void -sbp_rd_deinit(void) +sbp_rd_deinit() { gbfclose(file_handle); } static void -read_sbp_header(route_head* track) +read_sbp_header(route_head*) { /* * A complete SBP file contains 64 bytes header, @@ -83,7 +83,7 @@ read_sbp_header(route_head* track) } static Waypoint* -read_logpoint(void) +read_logpoint() { unsigned char buffer[SBP_RECORD_LEN]; @@ -95,7 +95,7 @@ read_logpoint(void) } static void -sbp_read(void) +sbp_read() { Waypoint* logpoint; route_head* track; @@ -111,7 +111,7 @@ sbp_read(void) } static void -sbp_exit(void) +sbp_exit() { } @@ -134,5 +134,7 @@ ff_vecs_t sbp_vecs = { sbp_args, CET_CHARSET_ASCII, 0 /* ascii is the expected character set */ /* not fixed, can be changed through command line parameter */ + , NULL_POS_OPS, + nullptr }; /**************************************************************************/ diff --git a/shape.cc b/shape.cc index 1256bc076..e1cb7e992 100644 --- a/shape.cc +++ b/shape.cc @@ -44,11 +44,11 @@ static arglist_t shp_args[] = { { "name", &opt_name, "Index of name field in .dbf", - NULL, ARGTYPE_STRING, "0", NULL + NULL, ARGTYPE_STRING, "0", NULL, nullptr }, { "url", &opt_url, "Index of URL field in .dbf", - NULL, ARGTYPE_INT, "0", NULL + NULL, ARGTYPE_INT, "0", NULL, nullptr }, ARG_TERMINATOR }; @@ -277,7 +277,7 @@ my_write_wpt(const Waypoint* wpt) } void -poly_init(const route_head* h) +poly_init(const route_head*) { int ct = track_waypt_count(); polybufx = (double*) xcalloc(ct, sizeof(double)); @@ -296,7 +296,7 @@ poly_point(const Waypoint* wpt) } void -poly_deinit(const route_head* h) +poly_deinit(const route_head*) { SHPObject* shpobject; shpobject = SHPCreateSimpleObject(SHPT_ARC, track_waypt_count(), @@ -355,5 +355,7 @@ ff_vecs_t shape_vecs = { NULL, shp_args, CET_CHARSET_ASCII, 0 /* CET-REVIEW */ + , NULL_POS_OPS, + nullptr }; #endif /* SHAPELIB_ENABLED */ diff --git a/skyforce.cc b/skyforce.cc index b5433925f..a8900248d 100644 --- a/skyforce.cc +++ b/skyforce.cc @@ -388,6 +388,8 @@ ff_vecs_t skyforce_vecs = { NULL, skyforce_args, CET_CHARSET_ASCII, 1 + , NULL_POS_OPS, + nullptr }; /**************************************************************************/ diff --git a/skytraq.cc b/skytraq.cc index ec7c959cc..91acaa981 100644 --- a/skytraq.cc +++ b/skytraq.cc @@ -1,1681 +1,1685 @@ -/* - Serial download of track data from GPS loggers with Skytraq chipset. - Copyright (C) 2008-2012 Mathias Adam, m.adam (at) adamis.de - 2008 J.C Haessig, jean-christophe.haessig (at) dianosis.org - 2009-09-06 | Josef Reisinger | Added "set target location", i.e. -i skytrag,targetlocation=: - 2010-10-23 | Josef Reisinger | Added read/write for miniHomer POI - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA - */ -#include "defs.h" -#include "gbser.h" -#include -#include -#include -#define MYNAME "skytraq" -#define TIMEOUT 5000 -#define SECTOR_SIZE 4096 -#define FULL_ITEM_LEN 18 -#define COMPACT_ITEM_LEN 8 -#define MULTI_HZ_ITEM_LEN 20 -/* Maximum number of chars to skip while waiting for a reply: */ -#define RETRIES 250 -/* Maximum number of messages to read while expecting a specific message or ACK/NACK: */ -#define MSG_RETRIES 3 -/* Abort when reading a specific sector fails this many times: */ -#define SECTOR_RETRIES 3 -#define res_OK 0 -#define res_ERROR -1 -#define res_NACK -2 -#define res_PROTOCOL_ERR -3 -#define res_NOTFOUND -4 -#define MIN(X,Y) ((X) < (Y) ? (X) : (Y)) -#define MAX(X,Y) ((X) > (Y) ? (X) : (Y)) -static void* serial_handle = 0; /* IO file descriptor */ -static int skytraq_baud = 0; /* detected baud rate */ -static gbfile* file_handle = 0; /* file descriptor (used by skytraq-bin format) */ -static char* opt_erase = 0; /* erase after read? (0/1) */ -static char* opt_initbaud = 0; /* baud rate used to init device */ -static char* opt_dlbaud = 0; /* baud rate used for downloading tracks */ -static char* opt_read_at_once = 0; /* number of sectors to read at once (Venus6 only) */ -static char* opt_first_sector = 0; /* first sector to be read from the device (default: 0) */ -static char* opt_last_sector = 0; /* last sector to be read from the device (default: smart read everything) */ -static char* opt_dump_file = 0; /* dump raw data to this file (optional) */ -static char* opt_no_output = 0; /* disable output? (0/1) */ -static char* opt_set_location = 0; /* set if the "targetlocation" options was used */ -static char* opt_configure_logging = 0; -static char* opt_gps_utc_offset = 0; -static -arglist_t skytraq_args[] = { - { - "erase", &opt_erase, "Erase device data after download", - "0", ARGTYPE_BOOL, ARG_NOMINMAX - }, - { - "targetlocation", &opt_set_location, "Set location finder target location as lat,lng", - NULL, ARGTYPE_STRING, "", "" - }, - { - "configlog", &opt_configure_logging, "Configure logging parameter as tmin:tmax:dmin:dmax", - NULL, ARGTYPE_STRING, "", "" - }, - { - "baud", &opt_dlbaud, "Baud rate used for download", - "230400", ARGTYPE_INT, "0", "230400" - }, - { - "initbaud", &opt_initbaud, "Baud rate used to init device (0=autodetect)", - "0", ARGTYPE_INT, "4800", "230400" - }, - { - "read-at-once", &opt_read_at_once, "Number of sectors to read at once (0=use single sector mode)", - "255", ARGTYPE_INT, "0", "255" - }, - { - "first-sector", &opt_first_sector, "First sector to be read from the device", - "0", ARGTYPE_INT, "0", "65535" - }, - { - "last-sector", &opt_last_sector, "Last sector to be read from the device (-1: smart read everything)", - "-1", ARGTYPE_INT, "-1", "65535" - }, - { - "dump-file", &opt_dump_file, "Dump raw data to this file", - NULL, ARGTYPE_OUTFILE, ARG_NOMINMAX - }, - { - "no-output", &opt_no_output, "Disable output (useful with erase)", - "0", ARGTYPE_BOOL, ARG_NOMINMAX - }, - { - "gps_utc_offset", &opt_gps_utc_offset, "Seconds that GPS time tracks UTC (0: best guess)", - "0", ARGTYPE_INT, ARG_NOMINMAX - }, - ARG_TERMINATOR -}; -static -arglist_t skytraq_fargs[] = { - { - "first-sector", &opt_first_sector, "First sector to be read from the file", - "0", ARGTYPE_INT, "0", "65535" - }, - { - "last-sector", &opt_last_sector, "Last sector to be read from the file (-1: read till empty sector)", - "-1", ARGTYPE_INT, "-1", "65535" - }, - { - "gps_utc_offset", &opt_gps_utc_offset, "Seconds that GPS time tracks UTC (0: best guess)", - "0", ARGTYPE_INT, ARG_NOMINMAX - }, - ARG_TERMINATOR -}; -static void -db(int l, const char* msg, ...) -{ - va_list ap; - va_start(ap, msg); - if (global_opts.debug_level >= l) { - vprintf(msg, ap); - } - va_end(ap); -} -static void -rd_drain(void) -{ - if (gbser_flush(serial_handle)) { - db(1, MYNAME ": rd_drain(): Comm error\n"); - } -} -static int -rd_char(int* errors) -{ - int c; - while (*errors > 0) { - c = gbser_readc_wait(serial_handle, TIMEOUT); - if (c < 0) { - db(1, MYNAME ": rd_char(): Got error: %d\n", c); - (*errors)--; - } else { - db(4, "rd_char(): Got char: %02x '%c'\n", c, isprint(c) ? c : '.'); - return c; - } - } - fatal(MYNAME ": Too many read errors on serial port\n"); - return -1; -} -static int -rd_buf(const uint8_t* buf, int len) -{ - int rc, timeout, i; - char dump[16*3+16+2]; - /* Allow TIMEOUT plus the time needed to actually receive the data bytes: - * baudrate/10 bytes per second (8 data bits, start and stop bit) - * TODO: use dlbaud if selected. - */ - timeout = TIMEOUT + len;//*1000/(skytraq_baud/10); - /*TODO: timeout gets <0 e.g. when len~=250000 --> 32bit signed int is too small. - if (skytraq_baud > 0) timeout = TIMEOUT + (long long int)len*1000*10/(long long int)skytraq_baud; - printf("len=%i skytraq_baud=%i timeout=%i\n", len, skytraq_baud, timeout);*/ - rc = gbser_read_wait(serial_handle, (void*)buf, len, timeout); - if (rc < 0) { - db(1, MYNAME ": rd_buf(): Read error (%d)\n", rc); - return res_ERROR; - } else if (rc < len) { - db(1, MYNAME ": rd_buf(): Read timout\n"); - return res_ERROR; - } - if (global_opts.debug_level >= 4) { - db(4, "rd_buf(): dump follows:\n"); - dump[sizeof(dump)-1] = 0; - for (i = 0; i < (len+15)/16*16; i++) { // count to next 16-byte boundary - if (i < len) { - snprintf(&dump[(i%16)*3], 4, "%02x ", buf[i]); - snprintf(&dump[3*16+1+(i%16)], 2, "%c", isprint(buf[i]) ? buf[i] : '.'); - } else { - memset(&dump[(i%16)*3], ' ', 3); - dump[3*16+1+(i%16)] = ' '; - } - if ((i+1)%16 == 0) { - dump[16*3] = ' '; // gets overwritten with 0 by snprintf - db(4, "%s\n", dump); - } - } - } - return res_OK; -} -static unsigned int -rd_word(void) -{ - int errors = 5; /* allow this many errors */ - uint8_t buffer[2]; - buffer[0] = rd_char(&errors); - buffer[1] = rd_char(&errors); - /* if (rd_buf(buffer, 2) != res_OK) { - db(1, MYNAME ": rd_word(): Read error\n"); - return res_ERROR; - }*/ - return (buffer[0] << 8) | buffer[1]; -} -static void -wr_char(int c) -{ - int rc; - db(4, "Sending: %02x '%c'\n", (unsigned)c, isprint(c) ? c : '.'); - if (rc = gbser_writec(serial_handle, c), gbser_OK != rc) { - fatal(MYNAME ": Write error (%d)\n", rc); - } -} -static void -wr_buf(const unsigned char* str, int len) -{ - int i; - for (i = 0; i < len; i++) { - wr_char(str[i]); - } -} -/******************************************************************************* -* %%% SkyTraq protocol implementation %%% * -*******************************************************************************/ -uint8_t NL[2] = { 0x0D, 0x0A }; -uint8_t MSG_START[2] = { 0xA0, 0xA1 }; -uint8_t SECTOR_READ_END[13] = { 'E','N','D', 0, 'C','H','E','C','K','S','U','M','=' }; -static int -skytraq_calc_checksum(const unsigned char* buf, int len) -{ - int i, cs = 0; - for (i = 0; i < len; i++) { - cs ^= buf[i]; - } - return cs; -} -static int -skytraq_rd_msg(const void* payload, unsigned int len) -{ - int errors = 5; /* allow this many errors */ - unsigned int c, i, state; - signed int rcv_len; - unsigned int calc_cs, rcv_cs; - for (i = 0, state = 0; i < RETRIES && state < sizeof(MSG_START); i++) { - c = rd_char(&errors); - if (c == MSG_START[state]) { - state++; - } else if (c == MSG_START[0]) { - state = 1; - } else { - state = 0; - } - } - if (state < sizeof(MSG_START)) { - db(1, MYNAME ": Didn't get message start tag\n"); - return res_ERROR; - } - if ((rcv_len = rd_word()) < len) { - if (rcv_len >= 0) { /* negative values indicate receive errors */ - db(1, MYNAME ": Received message too short (got %i bytes, expected %i)\n", - rcv_len, len); - return res_PROTOCOL_ERR; - } - return res_ERROR; - } - db(2, "Receiving message with %i bytes of payload (expected >=%i)\n", rcv_len, len); - rd_buf((const unsigned char*) payload, MIN(rcv_len, len)); - calc_cs = skytraq_calc_checksum((const unsigned char*) payload, MIN(rcv_len, len)); - for (i = 0; i < rcv_len-len; i++) { - c = rd_char(&errors); - calc_cs ^= c; - } - rcv_cs = rd_char(&errors); - if (rcv_cs != calc_cs) { - fatal(MYNAME ": Checksum error: got 0x%02x, expected 0x%02x\n", rcv_cs, calc_cs); - } - if (rd_word() != 0x0D0A) { - fatal(MYNAME ": Didn't get message end tag (CR/LF)\n"); - } -// return MIN(rcv_len, len); - return res_OK; -} -static void -skytraq_wr_msg(const uint8_t* payload, int len) -{ - int cs; - rd_drain(); - wr_buf(MSG_START, sizeof(MSG_START)); - wr_char((len>>8) & 0x0FF); - wr_char(len & 0x0FF); - wr_buf(payload, len); - cs = skytraq_calc_checksum(payload, len); - wr_char(cs); - wr_buf(NL, sizeof(NL)); -} -static int -skytraq_expect_ack(uint8_t id) -{ - uint8_t ack_msg[2]; - int i/*, rcv_len*/; - for (i = 0; i < MSG_RETRIES; i++) { -// rcv_len = skytraq_rd_msg(ack_msg, sizeof(ack_msg)); -// if (rcv_len == sizeof(ack_msg)) { - if (skytraq_rd_msg(ack_msg, sizeof(ack_msg)) == res_OK) { - if (ack_msg[0] == 0x83) { - if (ack_msg[1] == id) { - db(3, "Got ACK (id=0x%02x)\n", id); - return res_OK; - } else if (ack_msg[1] == 0) { - /* some (all?) devices first send an ACK with id==0, skip that */ - continue; - } else { - db(1, MYNAME ": Warning: Got unexpected ACK (id=0x%02x)\n", ack_msg[1]); - continue; - } - } else if (ack_msg[0] == 0x84) { - db(3, "Warning: Got NACK (id=0x%02x)\n", ack_msg[1]); - return res_NACK; - } else { - db(3, "Warning: Got unexpected message (id=0x%02x), expected ACK (id=0x%02x)\n", - ack_msg[0], id); - } - } else { - /* payload too short or didn't receive a message at all - -> caller should either resend request or give up. - */ - break; - } - } - return res_PROTOCOL_ERR; -} -static int -skytraq_expect_msg(uint8_t id, const uint8_t* payload, int len) -{ - int i, rc; - for (i = 0; i < MSG_RETRIES; i++) { - rc = skytraq_rd_msg(payload, len); - if (rc < 0) { - return rc; - } - if (payload[0] == id) { - return len; - } - } - return res_PROTOCOL_ERR; -} -static int -skytraq_wr_msg_verify(const uint8_t* payload, int len) -{ - int i, rc; - for (i = 0; i < MSG_RETRIES; i++) { - if (i > 0) { - db(1, "resending msg (id=0x%02x)...\n", payload[0]); - } - skytraq_wr_msg(payload, len); - rc = skytraq_expect_ack(payload[0]); - if (rc == res_OK || rc == res_NACK) { - return rc; - } - db(1, MYNAME ": Got neither ACK nor NACK, "); - } - db(1, "aborting (msg id was 0x%02x).\n", payload[0]); - return res_ERROR; -} -static int -skytraq_system_restart(void) -{ - uint8_t MSG_SYSTEM_RESTART[15] = - { 0x01, 0x01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - db(2, "restart system\n"); - return skytraq_wr_msg_verify(MSG_SYSTEM_RESTART, sizeof(MSG_SYSTEM_RESTART)); -} -static int -skytraq_set_baud(int baud) -{ - /* Note: according to AN0003_v3.pdf, attrib == 0x00 means write to SRAM only, however - * it seems to write to flash too. The Windows software sends 0x02 so we do here too. - */ - uint8_t MSG_CONFIGURE_SERIAL_PORT[4] - = { 0x05, 0x00, 0x00, 0x02 }; - int rc; - db(2, "Setting baud rate to %i\n", baud); - switch (baud) { - case 4800: - MSG_CONFIGURE_SERIAL_PORT[2] = 0; - break; - case 9600: - MSG_CONFIGURE_SERIAL_PORT[2] = 1; - break; - case 19200: - MSG_CONFIGURE_SERIAL_PORT[2] = 2; - break; - case 38400: - MSG_CONFIGURE_SERIAL_PORT[2] = 3; - break; - case 57600: - MSG_CONFIGURE_SERIAL_PORT[2] = 4; - break; - case 115200: - MSG_CONFIGURE_SERIAL_PORT[2] = 5; - break; - case 230400: - MSG_CONFIGURE_SERIAL_PORT[2] = 6; - break; - default: - fatal(MYNAME ": Unsupported baud rate: %ibd\n", baud); - } - rc = skytraq_wr_msg_verify(MSG_CONFIGURE_SERIAL_PORT, sizeof(MSG_CONFIGURE_SERIAL_PORT)); - if (rc != res_OK) { - db(2, "Warning: error setting skytraq device baud rate\n"); - return rc; - } - db(3, "Now setting UART baud rate to %i\n", baud); - rd_drain(); - if (gbser_set_speed(serial_handle, baud) != gbser_OK) { - db(2, "Warning: error setting uart baud rate\n"); - return res_ERROR; - } - gb_sleep(50); /* allow UART to settle. */ - return res_OK; -} -static int -skytraq_configure_logging(void) -{ - // an0008-1.4.14: logs if - // (dt > tmin & dd >= dmin & v >= vmin) | dt > tmax | dd > dmax | v > vmax - unsigned int tmin=6, tmax=3600, dmin=0, dmax=10000, nn=0; - uint8_t MSG_LOG_CONFIGURE_CONTROL[] = { - 0x18, // message_id - 0x00, 0x00, 0x0e, 0x10, // max_time: was 0x0000ffff (big endian!) - 0x00, 0x00, 0x00, 0x06, // min_time: was 0x00000005 - 0x00, 0x00, 0x27, 0x10, // max_distance: was 0x0000ffff - 0x00, 0x00, 0x00, 0x00, // min_distance - 0x00, 0x00, 0xff, 0xff, // max_speed - 0x00, 0x00, 0x00, 0x00, // min_speed - 0x01, // datalog_enable: NOTE: always ON - 0x00 // reserved - }; - if (opt_configure_logging) { - if (*opt_configure_logging) { - nn = sscanf(opt_configure_logging, "%u:%u:%u:%u", &tmin, &tmax, &dmin, &dmax); - if (nn>3) { - db(0, "Reconfiguring logging to: tmin=%u, tmax=%u, dmin=%u, dmax=%u\n", tmin, tmax, dmin, dmax); - be_write32(MSG_LOG_CONFIGURE_CONTROL+5, tmin); - be_write32(MSG_LOG_CONFIGURE_CONTROL+1, tmax); - be_write32(MSG_LOG_CONFIGURE_CONTROL+13, dmin); - be_write32(MSG_LOG_CONFIGURE_CONTROL+9, dmax); - } else { - db(1, MYNAME "Option usage: configlog=tmin:tmax:dmin:dmax"); - return -1; - } - } - } - return skytraq_wr_msg_verify(MSG_LOG_CONFIGURE_CONTROL, sizeof(MSG_LOG_CONFIGURE_CONTROL)); -} -static int -skytraq_get_log_buffer_status(uint32_t* log_wr_ptr, uint16_t* sectors_free, uint16_t* sectors_total) -{ - uint8_t MSG_LOG_STATUS_CONTROL = 0x17; - struct { - uint8_t id[1]; - uint8_t log_wr_ptr[4]; - uint8_t sectors_free[2]; - uint8_t sectors_total[2]; - uint8_t max_time[4], min_time[4], max_dist[4], min_dist[4], max_speed[4], min_speed[4]; - uint8_t datalog_enable[1], log_fifo_mode[1]; - } MSG_LOG_STATUS_OUTPUT; - unsigned int rc; - if ((rc = skytraq_wr_msg_verify(&MSG_LOG_STATUS_CONTROL, 1)) != res_OK) { /* get memory status */ - db(1, MYNAME ": Error sending LOG STATUS CONTROL message (%d)\n", rc); - return res_ERROR; - } - rc = skytraq_expect_msg(0x94, (uint8_t*)&MSG_LOG_STATUS_OUTPUT, sizeof(MSG_LOG_STATUS_OUTPUT)); - if (rc < sizeof(MSG_LOG_STATUS_OUTPUT)) { - db(1, MYNAME ": Didn't receive expected reply (%d)\n", rc); - return res_ERROR; - } - *log_wr_ptr = le_readu32(&MSG_LOG_STATUS_OUTPUT.log_wr_ptr); - *sectors_free = le_readu16(&MSG_LOG_STATUS_OUTPUT.sectors_free); - *sectors_total = le_readu16(&MSG_LOG_STATUS_OUTPUT.sectors_total); - // print logging parameters -- useful, but does this belong here? - unsigned int tmax, tmin, dmax, dmin, vmax, vmin; - // unsigned char log_bool, fifo_mode; - char* mystatus; - tmax = le_readu32(&MSG_LOG_STATUS_OUTPUT.max_time); - tmin = le_readu32(&MSG_LOG_STATUS_OUTPUT.min_time); - dmax = le_readu32(&MSG_LOG_STATUS_OUTPUT.max_dist); - dmin = le_readu32(&MSG_LOG_STATUS_OUTPUT.min_dist); - vmax = le_readu32(&MSG_LOG_STATUS_OUTPUT.max_speed); - vmin = le_readu32(&MSG_LOG_STATUS_OUTPUT.min_speed); - // log_bool = *(MSG_LOG_STATUS_OUTPUT.datalog_enable); - // fifo_mode = *(MSG_LOG_STATUS_OUTPUT.log_fifo_mode); - xasprintf(&mystatus, "#logging: tmin=%u, tmax=%u, dmin=%u, dmax=%u, vmin=%u, vmax=%u\n", tmin, tmax, dmin, dmax, vmin, vmax); - db(1, mystatus); - xfree(mystatus); - return res_OK; -} -/* reads 32-bit "middle-endian" fields */ -static unsigned int me_read32(const unsigned char* p) -{ - return ((unsigned)be_read16(p+2) << 16) | ((unsigned)be_read16(p)); -} -static time_t -gpstime_to_timet(int week, int sec) -{ - /* Notes: - * * assumes we're between the 1st and 2nd week rollover - * (i.e. between 22 Aug 1999 and 7 April 2019), so this - * should be taken care of before the next rollover... - * * list of leap seconds taken from - * - * as of 2012-10-12. Please update when necessary. - * Announcement of leap seconds: - * - * * leap seconds of 1999 JAN 1 and before are not reflected - * here, beware when using this for really old data - * * overflow of sec into next week is allowed - * (i.e. sec >= 7*24*3600 = 604800 is allowed) - */ - time_t gps_timet = 315964800; /* Jan 06 1980 0:00 UTC */ - gps_timet += (week+1024)*7*SECONDS_PER_DAY + sec; - int override = atoi(opt_gps_utc_offset); - if (override) { - gps_timet -= override; - return gps_timet; - } - /* leap second compensation: */ - gps_timet -= 13; /* diff GPS-UTC=13s (valid from Jan 01 1999 on) */ - if (gps_timet >= 1136073600) { /* Jan 01 2006 0:00 UTC */ - gps_timet--; /* GPS-UTC = 14s */ - } - if (gps_timet >= 1230768000) { /* Jan 01 2009 0:00 UTC */ - gps_timet--; /* GPS-UTC = 15s */ - } - if (gps_timet >= 1341100800) { /* Jul 01 2012 0:00 UTC */ - gps_timet--; /* GPS-UTC = 16s */ - } - if (gps_timet >= 1435708800) { /* Jul 01 2015 0:00 UTC */ - gps_timet--; /* GPS-UTC = 17s */ - } - if (gps_timet >= 1483228800) { /* Jan 01 2017 0:00 UTC */ - gps_timet--; /* GPS-UTC = 18s */ - } - // Future: Consult http://maia.usno.navy.mil/ser7/tai-utc.dat - // use http://www.stevegs.com/utils/jd_calc/ for Julian to UNIX sec - return gps_timet; /* returns UTC time */ -} -static void -ECEF_to_LLA(double x, double y, long z, double* lat, double* lon, double* alt) -{ - /* constants: */ - const double CA = 6378137.0; - const double CB = 6356752.31424518; - const double CE2 = (CA*CA - CB*CB) / (CA*CA); /* =e^2 */ - const double CE_2 = (CA*CA - CB*CB) / (CB*CB); /* =e'^2 */ - /* auxiliary values: */ - double AP = sqrt(x*x + y*y); - double ATHETA = atan2(z*CA, AP*CB); - /* latitude (in radians): */ - *lat = atan2(z + CE_2 * CB * pow(sin(ATHETA), 3), AP - CE2 * CA * pow(cos(ATHETA), 3)); - /* longitude (in radians): */ - *lon = atan2(y, x); - /* height above ellipsoid (in meters): */ - *alt = AP/cos(*lat) - CA/sqrt(1 - CE2 * pow(sin(*lat), 2)); - *lat = *lat /M_PI*180; - *lon = *lon /M_PI*180; -} -struct read_state { - route_head* route_head_; - unsigned wpn, tpn; - unsigned gps_week; - unsigned gps_sec; - long x, y, z; -}; -static void -state_init(struct read_state* pst) -{ - route_head* track; - track = route_head_alloc(); - track->rte_name = "SkyTraq tracklog"; - track->rte_desc = "SkyTraq GPS tracklog data"; - track_add_head(track); - pst->route_head_ = track; - pst->wpn = 0; - pst->tpn = 0; - pst->gps_week = 0; - pst->gps_sec = 0; - pst->x = 0; - pst->y = 0; - pst->z = 0; -} -static Waypoint* -make_trackpoint(struct read_state* st, double lat, double lon, double alt) -{ - Waypoint* wpt = new Waypoint; - wpt->shortname = QString().sprintf("TP%04d", ++st->tpn); - wpt->latitude = lat; - wpt->longitude = lon; - wpt->altitude = alt; - wpt->SetCreationTime(gpstime_to_timet(st->gps_week, st->gps_sec)); - return wpt; -} -typedef struct { - uint32_t gps_week; - uint32_t gps_sec; - int32_t x; - int32_t y; - int32_t z; -} full_item; -typedef struct { - uint16_t dt; - int16_t dx; - int16_t dy; - int16_t dz; -} compact_item; -typedef struct { - uint32_t gps_week; - uint32_t gps_sec; - int32_t lat; - int32_t lon; - int32_t alt; -} multi_hz_item; -struct full_item_frame { - unsigned char ts[4]; - unsigned char x[4]; - unsigned char y[4]; - unsigned char z[4]; -}; -struct compact_item_frame { - unsigned char dt[2]; /* big endian unsigned short */ - unsigned char dpos[4]; -}; -struct multi_hz_item_frame { - unsigned char v_kmh[2]; - unsigned char ts[4]; - unsigned char lat[4]; - unsigned char lon[4]; - unsigned char alt[4]; -}; -typedef struct { - unsigned char type_and_speed[2]; - union { - struct multi_hz_item_frame multi_hz; - struct full_item_frame full; - struct compact_item_frame comp; - }; -} item_frame; -#define ITEM_WEEK_NUMBER(item) (item->type_and_speed[1] | ((item->type_and_speed[0] & 0x03) << 8)) -#define POW_2_M20 0.000000953674316 -#define POW_2_M7 0.0078125 -#define ITEM_TYPE(item) (item->type_and_speed[0] >> 4) -#define ITEM_SPEED(item) (item->type_and_speed[1] | ((item->type_and_speed[0] & 0x0F) << 8)) -static int -process_data_item(struct read_state* pst, const item_frame* pitem, int len) -{ - int res = 0; - double lat, lon, alt, spe; - unsigned int ts; - int poi = 0; - full_item f; - compact_item c; - multi_hz_item m; - Waypoint* tpt = NULL; - switch (ITEM_TYPE(pitem)) { - case 0xc: /* POI item (same structure as full) */ - poi = 1; - /* fall through: */ - case 0x2: /* Multi HZ item */ - if (len < MULTI_HZ_ITEM_LEN) { - db(1, MYNAME ": Not enough bytes in sector for a full item.\n"); - return res_ERROR; - } - m.gps_week = ITEM_WEEK_NUMBER(pitem); - ts = me_read32(pitem->multi_hz.ts); - m.gps_sec = ((int)(ts & 0x3FFFFFFF)) / 1000; - m.lat = me_read32(pitem->multi_hz.lat); - m.lon = me_read32(pitem->multi_hz.lon); - m.alt = me_read32(pitem->multi_hz.alt); - pst->gps_week = m.gps_week; - pst->gps_sec = m.gps_sec; - spe = KPH_TO_MPS(be_read16(pitem->multi_hz.v_kmh)); - db(4, "Got multi hz item: week=%i sec=%i lat=%i lon=%i alt=%i speed=%f\n", - m.gps_week, m.gps_sec, - m.lat, m.lon, m.alt, - spe); - lat = m.lat * POW_2_M20; - lon = m.lon * POW_2_M20; - alt = m.alt * POW_2_M7; - tpt = make_trackpoint(pst, lat, lon, alt); - WAYPT_SET(tpt, speed, spe); /* convert speed to m/s */ - track_add_wpt(pst->route_head_, tpt); - res = MULTI_HZ_ITEM_LEN; - break; - case 0x6: /* POI item (same structure as full) */ - poi = 1; - /* fall through: */ - case 0x4: /* full item */ - if (len < FULL_ITEM_LEN) { - db(1, MYNAME ": Not enough bytes in sector for a full item.\n"); - return res_ERROR; - } - ts = me_read32(pitem->full.ts); - f.gps_week = ts & 0x000003FF; - f.gps_sec = ts >> 12; - f.x = me_read32(pitem->full.x); - f.y = me_read32(pitem->full.y); - f.z = me_read32(pitem->full.z); - pst->gps_week = f.gps_week; - pst->gps_sec = f.gps_sec; - pst->x = f.x; - pst->y = f.y; - pst->z = f.z; - db(4, "Got %s item: week=%i sec=%i x=%i y=%i z=%i speed=%i\n", - poi ? "POI" : "full", - f.gps_week, f.gps_sec, - f.x, f.y, f.z, - ITEM_SPEED(pitem)); - res = FULL_ITEM_LEN; - break; - case 0x8: /* compact item */ - if (len < COMPACT_ITEM_LEN) { - db(1, MYNAME ": Not enough bytes in sector for a compact item.\n"); - return res_ERROR; - } - c.dx = (pitem->comp.dpos[1] >> 6) | (pitem->comp.dpos[0] << 2); - c.dy = (pitem->comp.dpos[1] & 0x3F) | ((pitem->comp.dpos[2] & 0xF0) << 2); - c.dz = pitem->comp.dpos[3] | ((pitem->comp.dpos[2] & 0x03) << 8); - if (c.dx > 511) { - c.dx = 511-c.dx; /* make proper signed values */ - } - if (c.dy > 511) { - c.dy = 511-c.dy; - } - if (c.dz > 511) { - c.dz = 511-c.dz; - } - c.dt = (pitem->comp.dt[0] << 8) | pitem->comp.dt[1]; - db(4, "Got compact item: dt=%i dx=%i dy=%i dz=%i speed=%i uu=%i\n", - c.dt, c.dx, c.dy, c.dz, - ITEM_SPEED(pitem), (pitem->comp.dpos[2] & 0x0F)>>2); - pst->gps_sec += c.dt; - pst->x += c.dx; - pst->y += c.dy; - pst->z += c.dz; - res = COMPACT_ITEM_LEN; - break; - default: - db(1, MYNAME ": Unknown item type encountered: 0x%02x\n", ITEM_TYPE(pitem)); - return 0; - } - if (res == COMPACT_ITEM_LEN || res == FULL_ITEM_LEN) { - ECEF_to_LLA(pst->x, pst->y, pst->z, &lat, &lon, &alt); -// GPS_Math_XYZ_To_WGS84LatLonH(&lat, &lon, &alt, pst->x, pst->y, pst->z); - tpt = make_trackpoint(pst, lat, lon, alt); - WAYPT_SET(tpt, speed, KPH_TO_MPS(ITEM_SPEED(pitem))); /* convert speed to m/s */ - if (poi) { - waypt_add(new Waypoint(*tpt)); - } - if (0 == pst->route_head_) { - db(1, MYNAME ": New Track\n"); - pst->route_head_ = route_head_alloc(); - track_add_head(pst->route_head_); - } - track_add_wpt(pst->route_head_, tpt); - } - return res; -} -static int /* returns number of bytes processed (terminates on 0xFF i.e. empty or padding bytes) */ -process_data_sector(struct read_state* pst, const uint8_t* buf, int len) -{ - int plen, ilen; - for (plen = 0; plen < len && buf[plen] != 0xFF; plen += ilen) { - ilen = process_data_item(pst, (item_frame*)&buf[plen], len-plen); - if (ilen <= 0) { - fatal(MYNAME ": Error %i while processing data item #%i (starts at %i)\n", - ilen, pst->tpn, plen); - } - } - return plen; -} -/* Note: the buffer is being padded with 0xFFs if necessary so there are always SECTOR_SIZE valid bytes */ -static int -skytraq_read_single_sector(unsigned int sector, uint8_t* buf) -{ - uint8_t MSG_LOG_SECTOR_READ_CONTROL[2] = { 0x1B, (uint8_t)(sector) }; - int errors = 5; /* allow this many errors */ - unsigned int c, i, j, cs; - uint8_t buffer[16]; - if (sector > 0xFF) { - fatal(MYNAME ": Invalid sector number (%i)\n", sector); - } - db(2, "Reading sector #%i...\n", sector); - if (skytraq_wr_msg_verify((uint8_t*)&MSG_LOG_SECTOR_READ_CONTROL, sizeof(MSG_LOG_SECTOR_READ_CONTROL)) != res_OK) { - db(1, MYNAME ": Didn't receive ACK\n"); - return res_ERROR; - } -#ifdef READ_SINGLE_CHARS - for (i = 0, j = 0; i-j < SECTOR_SIZE && j < sizeof(SECTOR_READ_END); i++) { - c = rd_char(&errors); - buf[i] = c; - if (c == SECTOR_READ_END[j]) { - j++; - } else if (c == SECTOR_READ_END[0]) { - j = 1; - } else { - j = 0; - } - } - if (j < sizeof(SECTOR_READ_END)) { - db(1, MYNAME ": Didn't get sector end tag\n"); - return res_ERROR; - } - c = rd_char(&errors); /* read checksum byte */ - buf[i] = c; -#else - for (i = 0, j = 0; i-j < SECTOR_SIZE && j < sizeof(SECTOR_READ_END); i+=c) { - rd_buf(buffer, 16); - for (c = 0; c < 16 && j < sizeof(SECTOR_READ_END); c++) { - buf[i+c] = buffer[c]; - if (buffer[c] == SECTOR_READ_END[j]) { - j++; - } else if (buffer[c] == SECTOR_READ_END[0]) { - j = 1; - } else { - j = 0; - } - } - } - if (j < sizeof(SECTOR_READ_END)) { - db(1, MYNAME ": Didn't get sector end tag\n"); - return res_ERROR; - } - if (c < 16) { - buf[i] = buffer[c]; - } else { - c = rd_char(&errors); /* read checksum byte */ - buf[i] = c; - } -#endif - i = i-j; - db(3, "Received %i bytes of log data\n", i); -//#define SINGLE_READ_WORKAROUND -#ifdef SINGLE_READ_WORKAROUND - gbser_set_speed(serial_handle, skytraq_baud); - rd_char(&errors); - rd_char(&errors); - rd_char(&errors); - rd_char(&errors); - rd_char(&errors); - rd_char(&errors); - skytraq_set_baud(atoi(opt_dlbaud)); -#endif - cs = skytraq_calc_checksum(buf, i); - if (cs != buf[i+sizeof(SECTOR_READ_END)]) { - db(1, MYNAME ": Checksum error while reading sector: got 0x%02x, expected 0x%02x\n", - buf[i+sizeof(SECTOR_READ_END)], cs); - return res_ERROR; - } - for (; i < SECTOR_SIZE; i++) { - buf[i] = 0xFF; - } - return res_OK; -} -static int -skytraq_read_multiple_sectors(int first_sector, unsigned int sector_count, uint8_t* buf) -{ - uint8_t MSG_LOG_READ_MULTI_SECTORS[5] = { 0x1D }; - uint8_t* buf_end_tag; - unsigned int cs, i, read_result; - if (first_sector < 0 || first_sector > 0xFFFF) { - fatal(MYNAME ": Invalid sector number (%i)\n", first_sector); - } - be_write16(&MSG_LOG_READ_MULTI_SECTORS[1], first_sector); - if (sector_count > 0xFFFF) { - fatal(MYNAME ": Invalid sector count (%i)\n", sector_count); - } - be_write16(&MSG_LOG_READ_MULTI_SECTORS[3], sector_count); - db(2, "Reading %i sectors beginning from #%i...\n", sector_count, first_sector); - read_result = skytraq_wr_msg_verify((uint8_t*)&MSG_LOG_READ_MULTI_SECTORS, sizeof(MSG_LOG_READ_MULTI_SECTORS)); - if (read_result != res_OK) { - return read_result; - } - for (i = 0; i < sector_count; i++) { - db(2, "Receiving data of sector #%i...\n", first_sector+i); - rd_buf(buf+i*SECTOR_SIZE, SECTOR_SIZE); - } - rd_buf(buf+SECTOR_SIZE*sector_count, sizeof(SECTOR_READ_END)+6); - buf_end_tag = buf + SECTOR_SIZE*sector_count; - for (i = 0; i < sizeof(SECTOR_READ_END); i++) { - if (buf_end_tag[i] != SECTOR_READ_END[i]) { - db(1, MYNAME ": Wrong end tag: got 0x%02x ('%c'), expected 0x%02x ('%c')\n", - buf_end_tag[i], isprint(buf_end_tag[i]) ? buf_end_tag[i] : '.', - SECTOR_READ_END[i], isprint(SECTOR_READ_END[i]) ? SECTOR_READ_END[i] : '.'); - return res_ERROR; - } - } - cs = skytraq_calc_checksum(buf, SECTOR_SIZE*sector_count); - if (cs != buf_end_tag[sizeof(SECTOR_READ_END)]) { - db(1, MYNAME ": Checksum error while reading sector: got 0x%02x, expected 0x%02x\n", - buf_end_tag[sizeof(SECTOR_READ_END)], cs); - return res_ERROR; - } - return res_OK; -} -static void -skytraq_read_tracks(void) -{ - struct read_state st; - uint32_t log_wr_ptr; - uint16_t sectors_free, sectors_total, /*sectors_used_a, sectors_used_b,*/ sectors_used; - int i, t, s, rc, got_sectors, total_sectors_read = 0; - int read_at_once = MAX(atoi(opt_read_at_once), 1); - int opt_first_sector_val = atoi(opt_first_sector); - int opt_last_sector_val = atoi(opt_last_sector); - int multi_read_supported = 1; - uint8_t* buffer = NULL; - gbfile* dumpfile = NULL; - state_init(&st); - if (skytraq_get_log_buffer_status(&log_wr_ptr, §ors_free, §ors_total) != res_OK) { - fatal(MYNAME ": Can't get log buffer status\n"); - } - db(1, MYNAME ": Device status: free sectors: %i / total sectors: %i / %i%% used / write ptr: %i\n", - sectors_free, sectors_total, 100 - sectors_free*100 / sectors_total, log_wr_ptr); - if (opt_first_sector_val >= sectors_total) { - db(1, "Warning: sector# specified by option first-sector (%i) is beyond reported total sector count (%i)", - opt_first_sector_val, sectors_total); - } - /* Workaround: sectors_free is sometimes reported wrong. Tried to use log_wr_ptr as an - indicator for how many sectors are currently used. However this isn't correct in every case too. - The current read logic is aware of that so this shouldn't be necessary anymore. - sectors_used_a = sectors_total - sectors_free; - sectors_used_b = (log_wr_ptr + SECTOR_SIZE - 1) / SECTOR_SIZE; - if (sectors_used_a != sectors_used_b) { - db(1, "Warning: device reported inconsistent number of used sectors (a=%i, b=%i), "\ - "using max=%i\n", sectors_used_a, sectors_used_b, MAX(sectors_used_a, sectors_used_b)); - } - sectors_used = MAX(sectors_used_a, sectors_used_b); - */ - if (opt_last_sector_val < 0) { - sectors_used = sectors_total - sectors_free + 1 /*+5*/; - if (opt_first_sector_val >= sectors_used) { - sectors_used = opt_first_sector_val + 1; - } - } else { - sectors_used = opt_last_sector_val; - if (opt_last_sector_val >= sectors_total) { - db(1, "Warning: sector# specified by option last-sector (%i) is beyond reported total sector count (%i)", - opt_last_sector_val, sectors_total); - } - } - buffer = (uint8_t*) xmalloc(SECTOR_SIZE*read_at_once+sizeof(SECTOR_READ_END)+6); - // m.ad/090930: removed code that tried reducing read_at_once if necessary since doesn't work with xmalloc - if (opt_dump_file) { - dumpfile = gbfopen(opt_dump_file, "w", MYNAME); - } - db(1, MYNAME ": Reading log data from device...\n"); - db(1, MYNAME ": start=%d used=%d\n", opt_first_sector_val, sectors_used); - db(1, MYNAME ": opt_last_sector_val=%d\n", opt_last_sector_val); - for (i = opt_first_sector_val; i < sectors_used; i += got_sectors) { - for (t = 0, got_sectors = 0; (t < SECTOR_RETRIES) && (got_sectors <= 0); t++) { - if (atoi(opt_read_at_once) == 0 || multi_read_supported == 0) { - rc = skytraq_read_single_sector(i, buffer); - if (rc == res_OK) { - got_sectors = 1; - } - } else { - /* Try to read read_at_once sectors at once. - * If tere aren't any so many interesting ones, read the remainder (sectors_used-i). - * And read at least 1 sector. - */ - read_at_once = MAX(MIN(read_at_once, sectors_used-i), 1); - rc = skytraq_read_multiple_sectors(i, read_at_once, buffer); - switch (rc) { - case res_OK: - got_sectors = read_at_once; - read_at_once = MIN(read_at_once*2, atoi(opt_read_at_once)); - break; - case res_NACK: - db(1, MYNAME ": Device doesn't seem to support reading multiple " - "sectors at once, falling back to single read.\n"); - multi_read_supported = 0; - break; - default: - /* On failure, try with less sectors */ - read_at_once = MAX(read_at_once/2, 1); - } - } - } - if (got_sectors <= 0) { - fatal(MYNAME ": Error reading sector %i\n", i); - } - total_sectors_read += got_sectors; - if (dumpfile) { - gbfwrite(buffer, SECTOR_SIZE, got_sectors, dumpfile); - } - if (*opt_no_output == '1') { - continue; // skip decoding - } - for (s = 0; s < got_sectors; s++) { - db(4, MYNAME ": Decoding sector #%i...\n", i+s); - rc = process_data_sector(&st, buffer+s*SECTOR_SIZE, SECTOR_SIZE); - if (rc == 0) { - db(1, MYNAME ": Empty sector encountered: apparently only %i sectors are " - "used but device reported %i.\n", - i+s, sectors_used); - i = sectors_used; /* terminate to avoid reading stale data still in the logger */ - break; - } else if (rc >= (4096-FULL_ITEM_LEN) && i+s+1 >= sectors_used && i+s+1 < sectors_total) { - db(1, MYNAME ": Last sector is nearly full, reading one more sector\n"); - sectors_used++; - } - } - } - free(buffer); - db(1, MYNAME ": Got %i trackpoints from %i sectors.\n", st.tpn, total_sectors_read); - if (dumpfile) { - gbfclose(dumpfile); - } -} -static int -skytraq_probe(void) -{ - int baud_rates[] = { 9600, 230400, 115200, 57600, 4800, 19200, 38400 }; - int baud_rates_count = sizeof(baud_rates)/sizeof(baud_rates[0]); - int initbaud = atoi(opt_initbaud); - uint8_t MSG_QUERY_SOFTWARE_VERSION[2] = { 0x02, 0x01 }; - struct { - uint8_t id; - uint8_t sw_type; - uint8_t kernel_ver[4]; - uint8_t odm_ver[4]; - uint8_t revision[4]; - } MSG_SOFTWARE_VERSION; - int i, rc; - // TODO: get current serial port baud rate and try that first - // (only sensible if init to 4800 can be disabled...) - if (initbaud > 0) { - baud_rates[0] = initbaud; - baud_rates_count = 1; - } - for (i = 0; i < baud_rates_count; i++) { - db(1, MYNAME ": Probing SkyTraq Venus at %ibaud...\n", baud_rates[i]); - rd_drain(); - if ((rc = gbser_set_speed(serial_handle, baud_rates[i])) != gbser_OK) { - db(1, MYNAME ": Set baud rate to %d failed (%d), retrying...\n", baud_rates[i], rc); - if ((rc = gbser_set_speed(serial_handle, baud_rates[i])) != gbser_OK) { - db(1, MYNAME ": Set baud rate to %d failed (%d)\n", baud_rates[i], rc); - continue; - } - } - gb_sleep(50); /* allow UART to settle. */ - skytraq_wr_msg(MSG_QUERY_SOFTWARE_VERSION, /* get firmware version */ - sizeof(MSG_QUERY_SOFTWARE_VERSION)); - if ((rc = skytraq_expect_ack(0x02)) != res_OK) { - db(2, "Didn't receive ACK (%d), retrying...\n", rc); - skytraq_wr_msg(MSG_QUERY_SOFTWARE_VERSION, /* get firmware version */ - sizeof(MSG_QUERY_SOFTWARE_VERSION)); - if ((rc = skytraq_expect_ack(0x02)) != res_OK) { - db(2, "Didn't receive ACK (%d)\n", rc); - continue; - } - } - /* note: _verify retries on errors, probe takes too long. - if (skytraq_wr_msg_verify(MSG_QUERY_SOFTWARE_VERSION, - sizeof(MSG_QUERY_SOFTWARE_VERSION)) != res_OK) - { - continue; - }*/ - rc = skytraq_expect_msg(0x80, (uint8_t*)&MSG_SOFTWARE_VERSION, sizeof(MSG_SOFTWARE_VERSION)); - if (rc < (int)sizeof(MSG_SOFTWARE_VERSION)) { - db(2, "Didn't receive expected reply (%d)\n", rc); - } else { - db(1, MYNAME ": Venus device found: Kernel version = %i.%i.%i, ODM version = %i.%i.%i, "\ - "revision (Y/M/D) = %02i/%02i/%02i\n", - MSG_SOFTWARE_VERSION.kernel_ver[1], MSG_SOFTWARE_VERSION.kernel_ver[2], - MSG_SOFTWARE_VERSION.kernel_ver[3], - MSG_SOFTWARE_VERSION.odm_ver[1], MSG_SOFTWARE_VERSION.odm_ver[2], - MSG_SOFTWARE_VERSION.odm_ver[3], - MSG_SOFTWARE_VERSION.revision[1], MSG_SOFTWARE_VERSION.revision[2], - MSG_SOFTWARE_VERSION.revision[3]); - return baud_rates[i]; - } - } - return res_NOTFOUND; -} -static int -skytraq_erase() -{ - uint8_t MSG_LOG_ERASE = 0x19; - db(1, MYNAME ": Erasing logger memory...\n"); - if (skytraq_wr_msg_verify(&MSG_LOG_ERASE, sizeof(MSG_LOG_ERASE)) != res_OK) { - db(1, MYNAME ": Didn't receive ACK\n"); - return res_ERROR; - } - return res_OK; -} -static void -skytraq_set_location(void) -{ - double lat, lng; - unsigned int i; - uint8_t MSG_SET_LOCATION[17] = { 0x36, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - uint8_t MSG_GET_LOCATION = 0x35; - db(3, MYNAME ": set_location='%s'\n", opt_set_location); - sscanf(opt_set_location, "%lf:%lf", &lat, &lng); - le_write_double(&MSG_SET_LOCATION[1], lat); - le_write_double(&MSG_SET_LOCATION[9], lng); - for (i=0; i 0) { - db(4, MYNAME ": Seeking to first-sector index %i\n", opt_first_sector_val*SECTOR_SIZE); - gbfseek(file_handle, opt_first_sector_val*SECTOR_SIZE, SEEK_SET); - } - db(1, MYNAME ": Reading log data from file...\n"); - sectors_read = 0; - while ((got_bytes = gbfread(buffer, 1, SECTOR_SIZE, file_handle)) > 0) { - db(4, MYNAME ": Decoding sector #%i...\n", sectors_read++); - rc = process_data_sector(&st, buffer, got_bytes); - if (opt_last_sector_val < 0) { - if (rc < (4096-FULL_ITEM_LEN)) { - db(1, MYNAME ": Empty sector encountered, terminating.\n"); - break; - } - } else if (sectors_read-1 >= opt_last_sector_val) { - db(1, MYNAME ": desired last-sector #%i reached, terminating.\n", sectors_read-1); - break; - } - } - xfree(buffer); - db(1, MYNAME ": Got %i trackpoints from %i sectors.\n", st.tpn, sectors_read); -} -/**************************************************************************/ -// capabilities below means: we can only read tracks -ff_vecs_t skytraq_vecs = { - ff_type_serial, - { - ff_cap_read /* waypoints */, - ff_cap_read /* tracks */, - ff_cap_none /* routes */ - }, - skytraq_rd_init, - NULL, - skytraq_rd_deinit, - NULL, - skytraq_read, - NULL, - NULL, - skytraq_args, - CET_CHARSET_UTF8, 1 /* master process: don't convert anything */ -}; -ff_vecs_t skytraq_fvecs = { - ff_type_file, - { - ff_cap_read /* waypoints */, - ff_cap_read /* tracks */, - ff_cap_none /* routes */ - }, - file_init, - NULL, - file_deinit, - NULL, - file_read, - NULL, - NULL, - skytraq_fargs, - CET_CHARSET_UTF8, 1 /* master process: don't convert anything */ -}; -/**************************************************************************/ -/* - * support POI of skytraq based miniHomer device - * http://navin.com.tw/miniHomer.htm - * 2010-10-23 Josef Reisinger - */ -#ifdef MYNAME -#undef MYNAME -#endif -#define MYNAME "miniHomer" -static char* opt_set_poi_home = NULL; /* set if a "poi" option was used */ -static char* opt_set_poi_car = NULL; /* set if a "poi" option was used */ -static char* opt_set_poi_boat = NULL; /* set if a "poi" option was used */ -static char* opt_set_poi_heart = NULL; /* set if a "poi" option was used */ -static char* opt_set_poi_bar = NULL; /* set if a "poi" option was used */ -arglist_t miniHomer_args[] = { - { "baud", &opt_dlbaud, "Baud rate used for download", "115200", ARGTYPE_INT, "0", "115200" }, - { "dump-file", &opt_dump_file, "Dump raw data to this file", NULL, ARGTYPE_OUTFILE, ARG_NOMINMAX }, - { "erase", &opt_erase, "Erase device data after download", "0", ARGTYPE_BOOL, ARG_NOMINMAX }, - { "first-sector", &opt_first_sector, "First sector to be read from the device", "0", ARGTYPE_INT, "0", "65535" }, - { "initbaud", &opt_initbaud, "Baud rate used to init device (0=autodetect)", "38400", ARGTYPE_INT, "38400", "38400" }, - { "last-sector", &opt_last_sector, "Last sector to be read from the device (-1: smart read everything)", "-1", ARGTYPE_INT, "-1", "65535" }, - { "no-output", &opt_no_output, "Disable output (useful with erase)", "0", ARGTYPE_BOOL, ARG_NOMINMAX }, - { "read-at-once", &opt_read_at_once, "Number of sectors to read at once (0=use single sector mode)", "255", ARGTYPE_INT, "0", "255" }, - { "Home", &opt_set_poi_home, "POI for Home Symbol as lat:lng[:alt]", NULL, ARGTYPE_STRING, "", "" }, - { "Car", &opt_set_poi_car, "POI for Car Symbol as lat:lng[:alt]", NULL, ARGTYPE_STRING, "", "" }, - { "Boat", &opt_set_poi_boat, "POI for Boat Symbol as lat:lng[:alt]", NULL, ARGTYPE_STRING, "", "" }, - { "Heart", &opt_set_poi_heart, "POI for Heart Symbol as lat:lng[:alt]", NULL, ARGTYPE_STRING, "", "" }, - { "Bar", &opt_set_poi_bar, "POI for Bar Symbol as lat:lng[:alt]", NULL, ARGTYPE_STRING, "", "" }, - ARG_TERMINATOR -}; -/* - * Names of the POIs on miniHomer - */ -static const char* poinames[] = { - "Home", "Car", "Boat", "Heart", "Bar" -}; -#define NUMPOI (sizeof poinames/sizeof poinames[0]) -int getPoiByName(char* name) -{ - unsigned int i; - for (i=0; i>8)&0xff; - MSG_GET_POI[2]=(poi)&0xff; - if (skytraq_wr_msg_verify((uint8_t*)&MSG_GET_POI, sizeof(MSG_GET_POI)) != res_OK) { - warning(MYNAME ": cannot read poi %d '%s'\n", poi, poinames[poi]); - } - skytraq_rd_msg(buf, 25); - ecef_x=be_read_double(buf+1); - ecef_y=be_read_double(buf+9); - ecef_z=be_read_double(buf+17); - // todo - how to determine not-set POIs ? - if (ecef_x < 100.0 && ecef_y < 100.0 && ecef_z < 100.0) { - db(2, MYNAME" : skipped poi %d for X=%f, y=%f, Z=%f\n", ecef_x, ecef_y, ecef_z); - } else { - ECEF_to_LLA(ecef_x, ecef_y, ecef_z, &lat, &lng, &alt); - wpt = new Waypoint; - wpt->shortname = QString().sprintf("POI_%s", poinames[poi]); - wpt->description = QString().sprintf("miniHomer points to this coordinates if the %s symbol is on", poinames[poi]); - wpt->latitude = lat; - wpt->longitude = lng; - wpt->altitude = alt; - waypt_add(wpt); - db(1, MYNAME ": got POI[%s]='%f %f %f/%f %f %f'\n", poinames[poi], lat, lng, alt, ecef_x, ecef_y, ecef_z); - } - } -} -/* - * set lla (lat/lng/alt) specified as :[: to flash, 0->ro sram) - }; - int n, result; - double lat, lng, alt; - double ecef_x, ecef_y, ecef_z; - result=0; // result will be 0 if opt_poi isn't set - if (opt_poi) { // first check opt_poi - if (*opt_poi) { - lat=lng=alt=0.0; - /* - * parse format of :[:alt] - * we assume at least two elements in the value string - */ - n = sscanf(opt_poi, "%lf:%lf:%lf", &lat, &lng, &alt); - if (n >= 2) { - db(3, "found %d elems '%s':poi=%s@%d, lat=%f, lng=%f, alt=%f over=%s\n", n, opt_poi, poinames[poinum], poinum, lat, lng, alt); - lla2ecef(lat, lng, alt, &ecef_x, &ecef_y, &ecef_z); - db(1, MYNAME ": set POI[%s]='%f %f %f/%f %f %f'\n", poinames[poinum], lat, lng, alt, ecef_x, ecef_y, ecef_z); - be_write16(MSG_SET_POI+1, poinum); - be_write_double(MSG_SET_POI+3, ecef_x); - be_write_double(MSG_SET_POI+11, ecef_y); - be_write_double(MSG_SET_POI+19, ecef_z); - MSG_SET_POI[27]=0; - if (skytraq_wr_msg_verify((uint8_t*)&MSG_SET_POI, sizeof(MSG_SET_POI)) == res_OK) { - result=1; - } else { - warning(MYNAME ": cannot set poi %d '%s'\n", poinum, poinames[poinum]); - result=-1; - } - } else { - warning(MYNAME ": argument to %s needs to be like :[:]\n", poinames[poinum]); + + + + sizeof(MSG_QUERY_SOFTWARE_VERSION)); + sizeof(MSG_QUERY_SOFTWARE_VERSION)); + "sectors at once, falling back to single read.\n"); + ilen, pst->tpn, plen); + "used but device reported %i.\n", + ack_msg[0], id); + i+s, sectors_used); + -> caller should either resend request or give up. + /* On failure, try with less sectors */ + /* some (all?) devices first send an ACK with id==0, skip that */ + break; + break; + continue; + continue; + continue; + db(1, MYNAME ": Device doesn't seem to support reading multiple " + db(1, MYNAME ": Warning: Got unexpected ACK (id=0x%02x)\n", ack_msg[1]); + db(3, "Got ACK (id=0x%02x)\n", id); + got_sectors = 1; + got_sectors = read_at_once; + multi_read_supported = 0; + read_at_once = MAX(read_at_once/2, 1); + read_at_once = MIN(read_at_once*2, atoi(opt_read_at_once)); + result=-1; + result=1; + return res_OK; + sizeof(MSG_QUERY_SOFTWARE_VERSION)) != res_OK) + warning(MYNAME ": cannot set poi %d '%s'\n", poinum, poinames[poinum]); + "revision (Y/M/D) = %02i/%02i/%02i\n", + "using max=%i\n", sectors_used_a, sectors_used_b, MAX(sectors_used_a, sectors_used_b)); + * And read at least 1 sector. + * If tere aren't any so many interesting ones, read the remainder (sectors_used-i). + */ + buf_end_tag[i], isprint(buf_end_tag[i]) ? buf_end_tag[i] : '.', + MSG_SOFTWARE_VERSION.kernel_ver[1], MSG_SOFTWARE_VERSION.kernel_ver[2], + MSG_SOFTWARE_VERSION.kernel_ver[3], + MSG_SOFTWARE_VERSION.odm_ver[1], MSG_SOFTWARE_VERSION.odm_ver[2], + MSG_SOFTWARE_VERSION.odm_ver[3], + MSG_SOFTWARE_VERSION.revision[1], MSG_SOFTWARE_VERSION.revision[2], + MSG_SOFTWARE_VERSION.revision[3]); + opt_last_sector_val, sectors_total); + rcv_len, len); + SECTOR_READ_END[i], isprint(SECTOR_READ_END[i]) ? SECTOR_READ_END[i] : '.'); + /* Try to read read_at_once sectors at once. + be_write16(MSG_SET_POI+1, poinum); + be_write32(MSG_LOG_CONFIGURE_CONTROL+1, tmax); + be_write32(MSG_LOG_CONFIGURE_CONTROL+13, dmin); + be_write32(MSG_LOG_CONFIGURE_CONTROL+5, tmin); + be_write32(MSG_LOG_CONFIGURE_CONTROL+9, dmax); + be_write_double(MSG_SET_POI+11, ecef_y); + be_write_double(MSG_SET_POI+19, ecef_z); + be_write_double(MSG_SET_POI+3, ecef_x); + break; + break; + case res_NACK: + case res_OK: + continue; + continue; + db(0, "Reconfiguring logging to: tmin=%u, tmax=%u, dmin=%u, dmax=%u\n", tmin, tmax, dmin, dmax); + db(1, MYNAME ": Empty sector encountered, terminating.\n"); + db(1, MYNAME ": Empty sector encountered: apparently only %i sectors are " + db(1, MYNAME ": Last sector is nearly full, reading one more sector\n"); + db(1, MYNAME ": Set baud rate to %d failed (%d)\n", baud_rates[i], rc); + db(1, MYNAME ": set POI[%s]='%f %f %f/%f %f %f'\n", poinames[poinum], lat, lng, alt, ecef_x, ecef_y, ecef_z); + db(1, MYNAME "Option usage: configlog=tmin:tmax:dmin:dmax"); + db(2, "Didn't receive ACK (%d)\n", rc); + db(3, "found %d elems '%s':poi=%s@%d, lat=%f, lng=%f, alt=%f over=%s\n", n, opt_poi, poinames[poinum], poinum, lat, lng, alt); + db(3, "Warning: Got NACK (id=0x%02x)\n", ack_msg[1]); + db(3, "Warning: Got unexpected message (id=0x%02x), expected ACK (id=0x%02x)\n", + db(4, "%s\n", dump); + default: + dump[16*3] = ' '; // gets overwritten with 0 by snprintf + dump[3*16+1+(i%16)] = ' '; + i = sectors_used; /* terminate to avoid reading stale data still in the logger */ + if (ack_msg[1] == id) { + if (rc == res_OK) { + if (skytraq_wr_msg_verify((uint8_t*)&MSG_SET_POI, sizeof(MSG_SET_POI)) == res_OK) { + if (skytraq_wr_msg_verify(MSG_QUERY_SOFTWARE_VERSION, + j = 0; + j = 1; + j++; + lla2ecef(lat, lng, alt, &ecef_x, &ecef_y, &ecef_z); + memset(&dump[(i%16)*3], ' ', 3); + MSG_SET_POI[27]=0; + rc = skytraq_read_multiple_sectors(i, read_at_once, buffer); + rc = skytraq_read_single_sector(i, buffer); + read_at_once = MAX(MIN(read_at_once, sectors_used-i), 1); result=-1; + return -1; + return res_NACK; + sectors_used++; + snprintf(&dump[(i%16)*3], 4, "%02x ", buf[i]); + snprintf(&dump[3*16+1+(i%16)], 2, "%c", isprint(buf[i]) ? buf[i] : '.'); + switch (rc) { + warning(MYNAME ": argument to %s needs to be like :[:]\n", poinames[poinum]); + { + } + } + } + } + } else if (ack_msg[1] == 0) { + } else { + } else { + }*/ + * parse format of :[:alt] + * we assume at least two elements in the value string + */ + buf[i+sizeof(SECTOR_READ_END)], cs); + buf_end_tag[sizeof(SECTOR_READ_END)], cs); + c.dt, c.dx, c.dy, c.dz, + f.gps_week, f.gps_sec, + f.x, f.y, f.z, + ITEM_SPEED(pitem)); + ITEM_SPEED(pitem), (pitem->comp.dpos[2] & 0x0F)>>2); + m.gps_week, m.gps_sec, + m.lat, m.lon, m.alt, + opt_first_sector_val, sectors_total); + poi ? "POI" : "full", + spe); + (*errors)--; + */ + /* + /* payload too short or didn't receive a message at all + break; + break; + buf[i+c] = buffer[c]; + c.dx = 511-c.dx; /* make proper signed values */ + c.dy = 511-c.dy; + c.dz = 511-c.dz; + continue; // skip decoding + db(1, "resending msg (id=0x%02x)...\n", payload[0]); + db(1, "Warning: device reported inconsistent number of used sectors (a=%i, b=%i), "\ + db(1, "Warning: sector# specified by option last-sector (%i) is beyond reported total sector count (%i)", + db(1, MYNAME ": desired last-sector #%i reached, terminating.\n", sectors_read-1); + db(1, MYNAME ": got POI[%s]='%f %f %f/%f %f %f'\n", poinames[poi], lat, lng, alt, ecef_x, ecef_y, ecef_z); + db(1, MYNAME ": New Track\n"); + db(1, MYNAME ": Not enough bytes in sector for a compact item.\n"); + db(1, MYNAME ": Not enough bytes in sector for a full item.\n"); + db(1, MYNAME ": Not enough bytes in sector for a full item.\n"); + db(1, MYNAME ": rd_char(): Got error: %d\n", c); + db(1, MYNAME ": rd_word(): Read error\n"); + db(1, MYNAME ": Received message too short (got %i bytes, expected %i)\n", + db(1, MYNAME ": Set baud rate to %d failed (%d), retrying...\n", baud_rates[i], rc); + db(1, MYNAME ": Venus device found: Kernel version = %i.%i.%i, ODM version = %i.%i.%i, "\ + db(1, MYNAME ": Wrong end tag: got 0x%02x ('%c'), expected 0x%02x ('%c')\n", + db(2, "Didn't receive ACK (%d), retrying...\n", rc); + db(2, "Didn't receive expected reply (%d)\n", rc); + db(2, MYNAME" : skipped poi %d for X=%f, y=%f, Z=%f\n", ecef_x, ecef_y, ecef_z); + db(4, "rd_char(): Got char: %02x '%c'\n", c, isprint(c) ? c : '.'); + db(4, MYNAME ": Decoding sector #%i...\n", i+s); + ECEF_to_LLA(ecef_x, ecef_y, ecef_z, &lat, &lng, &alt); + fatal(MYNAME ": Error %i while processing data item #%i (starts at %i)\n", + fatal(MYNAME ": Error reading sector %i\n", i); + gbfwrite(buffer, SECTOR_SIZE, got_sectors, dumpfile); + if ((i+1)%16 == 0) { + if ((rc = gbser_set_speed(serial_handle, baud_rates[i])) != gbser_OK) { + if ((rc = skytraq_expect_ack(0x02)) != res_OK) { + if (ack_msg[0] == 0x83) { + if (atoi(opt_read_at_once) == 0 || multi_read_supported == 0) { + if (buffer[c] == SECTOR_READ_END[j]) { + if (i < len) { + if (n >= 2) { + if (nn>3) { + if (rc < (4096-FULL_ITEM_LEN)) { + if (rc == 0) { + j = 0; + j = 1; + j++; + lat=lng=alt=0.0; + n = sscanf(opt_poi, "%lf:%lf:%lf", &lat, &lng, &alt); + nn = sscanf(opt_configure_logging, "%u:%u:%u:%u", &tmin, &tmax, &dmin, &dmax); + pst->route_head_ = route_head_alloc(); + rc = process_data_sector(&st, buffer+s*SECTOR_SIZE, SECTOR_SIZE); + return baud_rates[i]; + return c; + return i; + return len; + return rc; + return rc; + return res_ERROR; + return res_ERROR; + return res_ERROR; + return res_ERROR; + return res_ERROR; + return res_PROTOCOL_ERR; + sectors_used = opt_first_sector_val + 1; + skytraq_wr_msg(MSG_QUERY_SOFTWARE_VERSION, /* get firmware version */ + state = 0; + state = 1; + state++; + track_add_head(pst->route_head_); + warning(MYNAME ": cannot read poi %d '%s'\n", poi, poinames[poi]); + waypt_add(new Waypoint(*tpt)); + waypt_add(wpt); + wpt = new Waypoint; + wpt->altitude = alt; + wpt->description = QString().sprintf("miniHomer points to this coordinates if the %s symbol is on", poinames[poi]); + wpt->latitude = lat; + wpt->longitude = lng; + wpt->shortname = QString().sprintf("POI_%s", poinames[poi]); } - } - } - return result; -} + } + } + } + } + } + } + } + } + } + } + } else if (ack_msg[0] == 0x84) { + } else if (buffer[c] == SECTOR_READ_END[0]) { + } else if (rc >= (4096-FULL_ITEM_LEN) && i+s+1 >= sectors_used && i+s+1 < sectors_total) { + } else { + } else { + } else { + } else { + } else { + } else { + indicator for how many sectors are currently used. However this isn't correct in every case too. + sectors_free, sectors_total, 100 - sectors_free*100 / sectors_total, log_wr_ptr); + The current read logic is aware of that so this shouldn't be necessary anymore. + "-1", ARGTYPE_INT, "-1", "65535", nullptr + "-1", ARGTYPE_INT, "-1", "65535", nullptr + "0", ARGTYPE_BOOL, ARG_NOMINMAX, nullptr + "0", ARGTYPE_BOOL, ARG_NOMINMAX, nullptr + "0", ARGTYPE_INT, "0", "65535", nullptr + "0", ARGTYPE_INT, "0", "65535", nullptr + "0", ARGTYPE_INT, "4800", "230400", nullptr + "0", ARGTYPE_INT, ARG_NOMINMAX, nullptr + "0", ARGTYPE_INT, ARG_NOMINMAX, nullptr + "230400", ARGTYPE_INT, "0", "230400", nullptr + "255", ARGTYPE_INT, "0", "255", nullptr + "baud", &opt_dlbaud, "Baud rate used for download", + "configlog", &opt_configure_logging, "Configure logging parameter as tmin:tmax:dmin:dmax", + "dump-file", &opt_dump_file, "Dump raw data to this file", + "erase", &opt_erase, "Erase device data after download", + "first-sector", &opt_first_sector, "First sector to be read from the device", + "first-sector", &opt_first_sector, "First sector to be read from the file", + "gps_utc_offset", &opt_gps_utc_offset, "Seconds that GPS time tracks UTC (0: best guess)", + "gps_utc_offset", &opt_gps_utc_offset, "Seconds that GPS time tracks UTC (0: best guess)", + "initbaud", &opt_initbaud, "Baud rate used to init device (0=autodetect)", + "last-sector", &opt_last_sector, "Last sector to be read from the device (-1: smart read everything)", + "last-sector", &opt_last_sector, "Last sector to be read from the file (-1: read till empty sector)", + "no-output", &opt_no_output, "Disable output (useful with erase)", + "read-at-once", &opt_read_at_once, "Number of sectors to read at once (0=use single sector mode)", + "targetlocation", &opt_set_location, "Set location finder target location as lat,lng", + (at your option) any later version. + /* note: _verify retries on errors, probe takes too long. + /* fall through: */ + /* fall through: */ + // todo - how to determine not-set POIs ? + // we need this call it initialized waypoint list etc... + 0 // attr (u8, 1-> to flash, 0->ro sram) + 0, 0, 0, 0, 0, 0, 0, 0, //alt (double ecef) + 0, 0, 0, 0, 0, 0, 0, 0, //lat (double ecef) + 0, 0, 0, 0, 0, 0, 0, 0, //lng (double ecef) + 0x00 // reserved + 0x00, 0x00, 0x00, 0x00, // min_distance + 0x00, 0x00, 0x00, 0x00, // min_speed + 0x00, 0x00, 0x00, 0x06, // min_time: was 0x00000005 + 0x00, 0x00, 0x0e, 0x10, // max_time: was 0x0000ffff (big endian!) + 0x00, 0x00, 0x27, 0x10, // max_distance: was 0x0000ffff + 0x00, 0x00, 0xff, 0xff, // max_speed + 0x01, // datalog_enable: NOTE: always ON + 0x18, // message_id + 0x4C, 0, 0, // cmd + poi (u16) + 2008 J.C Haessig, jean-christophe.haessig (at) dianosis.org + 2009-09-06 | Josef Reisinger | Added "set target location", i.e. -i skytrag,targetlocation=: + 2010-10-23 | Josef Reisinger | Added read/write for miniHomer POI + = { 0x05, 0x00, 0x00, 0x02 }; + along with this program; if not, write to the Free Software + alt = m.alt * POW_2_M7; + baud_rates[0] = initbaud; + baud_rates_count = 1; + break; + break; + break; + break; + break; + break; + break; + break; + break; + break; + buf[i] = 0xFF; + buf[i] = buffer[c]; + buf[i] = c; + buf[i] = c; + but WITHOUT ANY WARRANTY; without even the implied warranty of + c = gbser_readc_wait(serial_handle, TIMEOUT); + c = rd_char(&errors); + c = rd_char(&errors); + c = rd_char(&errors); + c = rd_char(&errors); /* read checksum byte */ + c.dt = (pitem->comp.dt[0] << 8) | pitem->comp.dt[1]; + c.dx = (pitem->comp.dpos[1] >> 6) | (pitem->comp.dpos[0] << 2); + c.dy = (pitem->comp.dpos[1] & 0x3F) | ((pitem->comp.dpos[2] & 0xF0) << 2); + c.dz = pitem->comp.dpos[3] | ((pitem->comp.dpos[2] & 0x03) << 8); + calc_cs ^= c; + char buf[32]; + Copyright (C) 2008-2012 Mathias Adam, m.adam (at) adamis.de + cs ^= buf[i]; + db(1, "Warning: sector# specified by option first-sector (%i) is beyond reported total sector count (%i)", + db(1, MYNAME ": Checksum error while reading sector: got 0x%02x, expected 0x%02x\n", + db(1, MYNAME ": Checksum error while reading sector: got 0x%02x, expected 0x%02x\n", + db(1, MYNAME ": Didn't get message start tag\n"); + db(1, MYNAME ": Didn't get sector end tag\n"); + db(1, MYNAME ": Didn't get sector end tag\n"); + db(1, MYNAME ": Didn't receive ACK\n"); + db(1, MYNAME ": Didn't receive ACK\n"); + db(1, MYNAME ": Didn't receive expected reply (%d)\n", rc); + db(1, MYNAME ": Error sending LOG STATUS CONTROL message (%d)\n", rc); + db(1, MYNAME ": Got neither ACK nor NACK, "); + db(1, MYNAME ": Probing SkyTraq Venus at %ibaud...\n", baud_rates[i]); + db(1, MYNAME ": rd_buf(): Read error (%d)\n", rc); + db(1, MYNAME ": rd_buf(): Read timout\n"); + db(1, MYNAME ": rd_drain(): Comm error\n"); + db(1, MYNAME ": Unknown item type encountered: 0x%02x\n", ITEM_TYPE(pitem)); + db(2, "Receiving data of sector #%i...\n", first_sector+i); + db(2, "Warning: error setting skytraq device baud rate\n"); + db(2, "Warning: error setting uart baud rate\n"); + db(3, "%02x ", MSG_SET_LOCATION[i]); + db(4, "Got %s item: week=%i sec=%i x=%i y=%i z=%i speed=%i\n", + db(4, "Got compact item: dt=%i dx=%i dy=%i dz=%i speed=%i uu=%i\n", + db(4, "Got multi hz item: week=%i sec=%i lat=%i lon=%i alt=%i speed=%f\n", + db(4, "rd_buf(): dump follows:\n"); + db(4, MYNAME ": Decoding sector #%i...\n", sectors_read++); + db(4, MYNAME ": Seeking to first-sector index %i\n", opt_first_sector_val*SECTOR_SIZE); + dump[sizeof(dump)-1] = 0; + dumpfile = gbfopen(opt_dump_file, "w", MYNAME); + ECEF_to_LLA(pst->x, pst->y, pst->z, &lat, &lon, &alt); + ecef_x=be_read_double(buf+1); + ecef_y=be_read_double(buf+9); + ecef_z=be_read_double(buf+17); + f.gps_sec = ts >> 12; + f.gps_week = ts & 0x000003FF; + f.x = me_read32(pitem->full.x); + f.y = me_read32(pitem->full.y); + f.z = me_read32(pitem->full.z); + fatal(MYNAME ": Can't find skytraq device on '%s'\n", qPrintable(fname)); + fatal(MYNAME ": Can't get log buffer status\n"); + fatal(MYNAME ": Can't open file '%s'\n", qPrintable(fname)); + fatal(MYNAME ": Can't open port '%s'\n", qPrintable(fname)); + fatal(MYNAME ": cannot set new location\n"); + fatal(MYNAME ": Checksum error: got 0x%02x, expected 0x%02x\n", rcv_cs, calc_cs); + fatal(MYNAME ": Didn't get message end tag (CR/LF)\n"); + fatal(MYNAME ": Invalid sector count (%i)\n", sector_count); + fatal(MYNAME ": Invalid sector number (%i)\n", first_sector); + fatal(MYNAME ": Invalid sector number (%i)\n", sector); + fatal(MYNAME ": Unsupported baud rate: %ibd\n", baud); + fatal(MYNAME ": Write error (%d)\n", rc); + ff_cap_none /* routes */ + ff_cap_none /* routes */ + ff_cap_none /* routes */ + ff_cap_read /* tracks */, + ff_cap_read /* tracks */, + ff_cap_read /* tracks */, + ff_cap_read /* waypoints */, + ff_cap_read /* waypoints */, + ff_cap_read /* waypoints */, + for (c = 0; c < 16 && j < sizeof(SECTOR_READ_END); c++) { + for (i = 0; i < (len+15)/16*16; i++) { // count to next 16-byte boundary + for (s = 0; s < got_sectors; s++) { + for (t = 0, got_sectors = 0; (t < SECTOR_RETRIES) && (got_sectors <= 0); t++) { + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA + gb_sleep(50); /* allow UART to settle. */ + gbfclose(dumpfile); + gbfseek(file_handle, opt_first_sector_val*SECTOR_SIZE, SEEK_SET); + GNU General Public License for more details. + gps_timet -= override; + gps_timet--; /* GPS-UTC = 14s */ + gps_timet--; /* GPS-UTC = 15s */ + gps_timet--; /* GPS-UTC = 16s */ + gps_timet--; /* GPS-UTC = 17s */ + gps_timet--; /* GPS-UTC = 18s */ + if ((rc = gbser_set_speed(serial_handle, baud_rates[i])) != gbser_OK) { + if ((rc = skytraq_expect_ack(0x02)) != res_OK) { + if (*opt_configure_logging) { + if (*opt_no_output == '1') { + if (*opt_poi) { + if (0 == pst->route_head_) { + if (buf_end_tag[i] != SECTOR_READ_END[i]) { + if (c < 0) { + if (c == MSG_START[state]) { + if (c == SECTOR_READ_END[j]) { + if (c.dx > 511) { + if (c.dy > 511) { + if (c.dz > 511) { + if (dumpfile) { + if (ecef_x < 100.0 && ecef_y < 100.0 && ecef_z < 100.0) { + if (got_sectors <= 0) { + if (i > 0) { + if (ilen <= 0) { + if (len < COMPACT_ITEM_LEN) { + if (len < FULL_ITEM_LEN) { + if (len < MULTI_HZ_ITEM_LEN) { + if (opt_first_sector_val >= sectors_used) { + if (opt_last_sector_val < 0) { + if (opt_last_sector_val >= sectors_total) { + if (payload[0] == id) { + if (poi) { + if (rc < (int)sizeof(MSG_SOFTWARE_VERSION)) { + if (rc < 0) { + if (rc == res_OK || rc == res_NACK) { + if (rcv_len >= 0) { /* negative values indicate receive errors */ + if (sectors_used_a != sectors_used_b) { + if (skytraq_baud > 0) timeout = TIMEOUT + (long long int)len*1000*10/(long long int)skytraq_baud; + if (skytraq_rd_msg(ack_msg, sizeof(ack_msg)) == res_OK) { + if (skytraq_wr_msg_verify((uint8_t*)&MSG_GET_POI, sizeof(MSG_GET_POI)) != res_OK) { + if (strcmp(poinames[i], name) == 0) { + ilen = process_data_item(pst, (item_frame*)&buf[plen], len-plen); + it under the terms of the GNU General Public License as published by + lat = m.lat * POW_2_M20; + lon = m.lon * POW_2_M20; + m.alt = me_read32(pitem->multi_hz.alt); + m.gps_sec = ((int)(ts & 0x3FFFFFFF)) / 1000; + m.gps_week = ITEM_WEEK_NUMBER(pitem); + m.lat = me_read32(pitem->multi_hz.lat); + m.lon = me_read32(pitem->multi_hz.lon); + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + miniHomer_get_poi(); // add POI as waypoints to the waypoints of the track + MSG_CONFIGURE_SERIAL_PORT[2] = 0; + MSG_CONFIGURE_SERIAL_PORT[2] = 1; + MSG_CONFIGURE_SERIAL_PORT[2] = 2; + MSG_CONFIGURE_SERIAL_PORT[2] = 3; + MSG_CONFIGURE_SERIAL_PORT[2] = 4; + MSG_CONFIGURE_SERIAL_PORT[2] = 5; + MSG_CONFIGURE_SERIAL_PORT[2] = 6; + MSG_GET_POI[1]=(poi>>8)&0xff; + MSG_GET_POI[2]=(poi)&0xff; + npoi++; + npoi++; + npoi++; + npoi++; + npoi++; + NULL, ARGTYPE_OUTFILE, ARG_NOMINMAX, nullptr + NULL, ARGTYPE_STRING, "", "", nullptr + NULL, ARGTYPE_STRING, "", "", nullptr + poi = 1; + poi = 1; + pst->gps_sec += c.dt; + pst->gps_sec = f.gps_sec; + pst->gps_sec = m.gps_sec; + pst->gps_week = f.gps_week; + pst->gps_week = m.gps_week; + pst->x += c.dx; + pst->x = f.x; + pst->y += c.dy; + pst->y = f.y; + pst->z += c.dz; + pst->z = f.z; + rc = process_data_sector(&st, buffer, got_bytes); + rc = skytraq_expect_ack(payload[0]); + rc = skytraq_expect_msg(0x80, (uint8_t*)&MSG_SOFTWARE_VERSION, sizeof(MSG_SOFTWARE_VERSION)); + rc = skytraq_rd_msg(payload, len); + rd_buf(buf+i*SECTOR_SIZE, SECTOR_SIZE); + rd_buf(buffer, 16); + rd_drain(); + res = COMPACT_ITEM_LEN; + res = FULL_ITEM_LEN; + res = MULTI_HZ_ITEM_LEN; + return 0; + return gps_timet; + return rc; + return read_result; + return res_ERROR; + return res_ERROR; + return res_ERROR; + return res_ERROR; + return res_ERROR; + return res_ERROR; + return res_ERROR; + return res_ERROR; + return res_ERROR; + return res_ERROR; + return res_ERROR; + return res_ERROR; + return res_ERROR; + return; + return; + sectors_used = MAX(sectors_used_a, sectors_used_b); + sectors_used = opt_last_sector_val; + sectors_used = sectors_total - sectors_free + 1 /*+5*/; + sectors_used_a = sectors_total - sectors_free; + sectors_used_b = (log_wr_ptr + SECTOR_SIZE - 1) / SECTOR_SIZE; + Serial download of track data from GPS loggers with Skytraq chipset. + skytraq_configure_logging(); + skytraq_erase(); + skytraq_rd_deinit(); // skytraq_read called system_reset, which changes the baud rate. + skytraq_rd_init(mhport); // Lets start from scratch and re-init the port + skytraq_rd_msg(buf, 25); + skytraq_rd_msg(buf, 32); + skytraq_read(); // first read tracks (if not supressed by cmd line params) + skytraq_read_tracks(); + skytraq_set_baud(dlbaud); + skytraq_set_baud(skytraq_baud); // note that _system_restart resets baud rate anyway... + skytraq_set_location(); + skytraq_wr_msg(MSG_QUERY_SOFTWARE_VERSION, /* get firmware version */ + skytraq_wr_msg(payload, len); + skytraq_wr_msg_verify(&MSG_GET_LOCATION, 1); + spe = KPH_TO_MPS(be_read16(pitem->multi_hz.v_kmh)); + struct compact_item_frame comp; + struct full_item_frame full; + struct multi_hz_item_frame multi_hz; + the Free Software Foundation; either version 2 of the License, or + This program is distributed in the hope that it will be useful, + This program is free software; you can redistribute it and/or modify + total_sectors_read += got_sectors; + tpt = make_trackpoint(pst, lat, lon, alt); + tpt = make_trackpoint(pst, lat, lon, alt); + track_add_wpt(pst->route_head_, tpt); + track_add_wpt(pst->route_head_, tpt); + ts = me_read32(pitem->full.ts); + ts = me_read32(pitem->multi_hz.ts); + uint8_t datalog_enable[1], log_fifo_mode[1]; + uint8_t id; + uint8_t id[1]; + uint8_t kernel_ver[4]; + uint8_t log_wr_ptr[4]; + uint8_t max_time[4], min_time[4], max_dist[4], min_dist[4], max_speed[4], min_speed[4]; + uint8_t odm_ver[4]; + uint8_t revision[4]; + uint8_t sectors_free[2]; + uint8_t sectors_total[2]; + uint8_t sw_type; + vprintf(msg, ap); + WAYPT_SET(tpt, speed, KPH_TO_MPS(ITEM_SPEED(pitem))); /* convert speed to m/s */ + WAYPT_SET(tpt, speed, spe); /* convert speed to m/s */ + wr_char(str[i]); + You should have received a copy of the GNU General Public License + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } else if (c == MSG_START[0]) { + } else if (c == SECTOR_READ_END[0]) { + } else if (sectors_read-1 >= opt_last_sector_val) { + } else { + } else { + } else { + } else { + } else { + } else { + }*/ + * (i.e. between 22 Aug 1999 and 7 April 2019), so this + * (i.e. sec >= 7*24*3600 = 604800 is allowed) + * + * + * Announcement of leap seconds: + * as of 2012-10-12. Please update when necessary. + * here, beware when using this for really old data + * should be taken care of before the next rollover... + * * assumes we're between the 1st and 2nd week rollover + * * leap seconds of 1999 JAN 1 and before are not reflected + * * list of leap seconds taken from + * * overflow of sec into next week is allowed + * baudrate/10 bytes per second (8 data bits, start and stop bit) + * it seems to write to flash too. The Windows software sends 0x02 so we do here too. + * read tracks and POI from miniHomer + * TODO: use dlbaud if selected. + */ + */ + */ + */ + "Home", "Car", "Boat", "Heart", "Bar" + */ + *alt = AP/cos(*lat) - CA/sqrt(1 - CE2 * pow(sin(*lat), 2)); + *ecef_x = (double)((n+lalt) * cos(llat) * cos(llng)); + *ecef_y = (double)((n+lalt) * cos(llat) * sin(llng)); + *ecef_z = (double)((n*(1-esqr) + lalt)* sin(llat)); + *lat = *lat /M_PI*180; + *lat = atan2(z + CE_2 * CB * pow(sin(ATHETA), 3), AP - CE2 * CA * pow(cos(ATHETA), 3)); + *log_wr_ptr = le_readu32(&MSG_LOG_STATUS_OUTPUT.log_wr_ptr); + *lon = *lon /M_PI*180; + *lon = atan2(y, x); + *sectors_free = le_readu16(&MSG_LOG_STATUS_OUTPUT.sectors_free); + *sectors_total = le_readu16(&MSG_LOG_STATUS_OUTPUT.sectors_total); + , NULL_POS_OPS, + , NULL_POS_OPS, + /* + /* if (rd_buf(buffer, 2) != res_OK) { + /* Allow TIMEOUT plus the time needed to actually receive the data bytes: + /* auxiliary values: */ + /* constants: */ + /* height above ellipsoid (in meters): */ + /* latitude (in radians): */ + /* leap second compensation: */ + /* longitude (in radians): */ + /* Note: according to AN0003_v3.pdf, attrib == 0x00 means write to SRAM only, however + /* Notes: + /* Workaround: sectors_free is sometimes reported wrong. Tried to use log_wr_ptr as an + /*TODO: timeout gets <0 e.g. when len~=250000 --> 32bit signed int is too small. + // (dt > tmin & dd >= dmin & v >= vmin) | dt > tmax | dd > dmax | v > vmax + // (only sensible if init to 4800 can be disabled...) + // an0008-1.4.14: logs if + // fifo_mode = *(MSG_LOG_STATUS_OUTPUT.log_fifo_mode); + // Future: Consult http://maia.usno.navy.mil/ser7/tai-utc.dat + // log_bool = *(MSG_LOG_STATUS_OUTPUT.datalog_enable); + // m.ad/090930: removed code that tried reducing read_at_once if necessary since doesn't work with xmalloc + // print logging parameters -- useful, but does this belong here? + // read device unless no-output=1 and dump-file=0 (i.e. no data needed at all) + // TODO: get current serial port baud rate and try that first + // unsigned char log_bool, fifo_mode; + // use http://www.stevegs.com/utils/jd_calc/ for Julian to UNIX sec + ARG_TERMINATOR + ARG_TERMINATOR + ARG_TERMINATOR + be_write16(&MSG_LOG_READ_MULTI_SECTORS[1], first_sector); + be_write16(&MSG_LOG_READ_MULTI_SECTORS[3], sector_count); + buf[i] = c; + buf_end_tag = buf + SECTOR_SIZE*sector_count; + buffer = (uint8_t*) xmalloc(SECTOR_SIZE); + buffer = (uint8_t*) xmalloc(SECTOR_SIZE*read_at_once+sizeof(SECTOR_READ_END)+6); + buffer[0] = rd_char(&errors); + buffer[1] = rd_char(&errors); + c = rd_char(&errors); /* read checksum byte */ + calc_cs = skytraq_calc_checksum((const unsigned char*) payload, MIN(rcv_len, len)); + case 0x2: /* Multi HZ item */ + case 0x4: /* full item */ + case 0x6: /* POI item (same structure as full) */ + case 0x8: /* compact item */ + case 0xc: /* POI item (same structure as full) */ + case 115200: + case 19200: + case 230400: + case 38400: + case 4800: + case 57600: + case 9600: + CET_CHARSET_UTF8, 1 /* master process: don't convert anything */ + CET_CHARSET_UTF8, 1 /* master process: don't convert anything */ + CET_CHARSET_UTF8, 1 /* master process: don't convert anything */ + char dump[16*3+16+2]; + char* mystatus; + compact_item c; + const double CA = 6378137.0; + const double CB = 6356752.31424518; + const double CE2 = (CA*CA - CB*CB) / (CA*CA); /* =e^2 */ + const double CE_2 = (CA*CA - CB*CB) / (CB*CB); /* =e'^2 */ + cs = skytraq_calc_checksum(buf, i); + cs = skytraq_calc_checksum(buf, SECTOR_SIZE*sector_count); + cs = skytraq_calc_checksum(payload, len); + db(1, "aborting (msg id was 0x%02x).\n", payload[0]); + db(1, "Closing file...\n"); + db(1, "Opening file...\n"); + db(1, MYNAME ": Device status: free sectors: %i / total sectors: %i / %i%% used / write ptr: %i\n", + db(1, MYNAME ": Erasing logger memory...\n"); + db(1, MYNAME ": Got %i trackpoints from %i sectors.\n", st.tpn, sectors_read); + db(1, MYNAME ": Got %i trackpoints from %i sectors.\n", st.tpn, total_sectors_read); + db(1, MYNAME ": opt_last_sector_val=%d\n", opt_last_sector_val); + db(1, MYNAME ": Reading log data from device...\n"); + db(1, MYNAME ": Reading log data from file...\n"); + db(1, MYNAME ": start=%d used=%d\n", opt_first_sector_val, sectors_used); + db(1, mystatus); + db(2, "Reading %i sectors beginning from #%i...\n", sector_count, first_sector); + db(2, "Reading sector #%i...\n", sector); + db(2, "Receiving message with %i bytes of payload (expected >=%i)\n", rcv_len, len); + db(2, "restart system\n"); + db(2, "Setting baud rate to %i\n", baud); + db(3, "\n"); + db(3, "Now setting UART baud rate to %i\n", baud); + db(3, "Received %i bytes of log data\n", i); + db(3, MYNAME ": set_location='%s'\n", opt_set_location); + db(4, "Sending: %02x '%c'\n", (unsigned)c, isprint(c) ? c : '.'); + default: + default: + dlbaud = atoi(opt_dlbaud); + dmax = le_readu32(&MSG_LOG_STATUS_OUTPUT.max_dist); + dmin = le_readu32(&MSG_LOG_STATUS_OUTPUT.min_dist); + double AP = sqrt(x*x + y*y); + double ATHETA = atan2(z*CA, AP*CB); + double ecef_x, ecef_y, ecef_z; + double ecef_x, ecef_y, ecef_z; + double lat, lng, alt; + double lat, lng, alt; + double lat, lng; + double lat, lon, alt, spe; + fatal(MYNAME ": Too many read errors on serial port\n"); + ff_type_file, + ff_type_serial, + ff_type_serial, + file_deinit, + file_handle = NULL; + file_init, + file_read, + for (; i < SECTOR_SIZE; i++) { + for (i = 0, j = 0; i-j < SECTOR_SIZE && j < sizeof(SECTOR_READ_END); i++) { + for (i = 0, j = 0; i-j < SECTOR_SIZE && j < sizeof(SECTOR_READ_END); i+=c) { + for (i = 0, state = 0; i < RETRIES && state < sizeof(MSG_START); i++) { + for (i = 0; i < baud_rates_count; i++) { + for (i = 0; i < len; i++) { + for (i = 0; i < len; i++) { + for (i = 0; i < MSG_RETRIES; i++) { + for (i = 0; i < MSG_RETRIES; i++) { + for (i = 0; i < MSG_RETRIES; i++) { + for (i = 0; i < rcv_len-len; i++) { + for (i = 0; i < sector_count; i++) { + for (i = 0; i < sizeof(SECTOR_READ_END); i++) { + for (i = opt_first_sector_val; i < sectors_used; i += got_sectors) { + for (i=0; i 0xFFFF) { + if (gbser_flush(serial_handle)) { + if (gbser_set_speed(serial_handle, baud) != gbser_OK) { + if (global_opts.debug_level >= 4) { + if (global_opts.debug_level >= l) { + if (gps_timet >= 1136073600) { /* Jan 01 2006 0:00 UTC */ + if (gps_timet >= 1230768000) { /* Jan 01 2009 0:00 UTC */ + if (gps_timet >= 1341100800) { /* Jul 01 2012 0:00 UTC */ + if (gps_timet >= 1435708800) { /* Jul 01 2015 0:00 UTC */ + if (gps_timet >= 1483228800) { /* Jan 01 2017 0:00 UTC */ + if (initbaud > 0) { + if (j < sizeof(SECTOR_READ_END)) { + if (j < sizeof(SECTOR_READ_END)) { + if (miniHomer_set_poi(0, opt_set_poi_home) > 0) { + if (miniHomer_set_poi(1, opt_set_poi_car) > 0) { + if (miniHomer_set_poi(2, opt_set_poi_boat) > 0) { + if (miniHomer_set_poi(3, opt_set_poi_heart) > 0) { + if (miniHomer_set_poi(4, opt_set_poi_bar) > 0) { + if (npoi == 0) { // do not read if POIs are set (consider set & read distinct operations) + if (opt_configure_logging) { + if (opt_configure_logging) { + if (opt_dump_file) { + if (opt_first_sector_val > 0) { + if (opt_first_sector_val >= sectors_total) { + if (opt_last_sector_val < 0) { + if (opt_poi) { // first check opt_poi + if (opt_set_location) { + if (override) { + if (rc != res_OK) { + if (rc < 0) { + if (rc < sizeof(MSG_LOG_STATUS_OUTPUT)) { + if (rc = gbser_writec(serial_handle, c), gbser_OK != rc) { + if (rcv_cs != calc_cs) { + if (rd_word() != 0x0D0A) { + if (read_result != res_OK) { + if (res == COMPACT_ITEM_LEN || res == FULL_ITEM_LEN) { + if (sector > 0xFF) { + if (sector_count > 0xFFFF) { + if (skytraq_get_log_buffer_status(&log_wr_ptr, §ors_free, §ors_total) != res_OK) { + if (skytraq_wr_msg_verify(&MSG_LOG_ERASE, sizeof(MSG_LOG_ERASE)) != res_OK) { + if (skytraq_wr_msg_verify((uint8_t*)&MSG_LOG_SECTOR_READ_CONTROL, sizeof(MSG_LOG_SECTOR_READ_CONTROL)) != res_OK) { + if (skytraq_wr_msg_verify((uint8_t*)&MSG_SET_LOCATION, sizeof(MSG_SET_LOCATION)) != res_OK) { + if (state < sizeof(MSG_START)) { + int baud_rates[] = { 9600, 230400, 115200, 57600, 4800, 19200, 38400 }; + int baud_rates_count = sizeof(baud_rates)/sizeof(baud_rates[0]); + int c; + int cs; + int dlbaud; + int errors = 5; /* allow this many errors */ + int errors = 5; /* allow this many errors */ + int errors = 5; /* allow this many errors */ + int i, cs = 0; + int i, rc; + int i, rc; + int i, rc; + int i, t, s, rc, got_sectors, total_sectors_read = 0; + int i/*, rcv_len*/; + int i; + int initbaud = atoi(opt_initbaud); + int multi_read_supported = 1; + int n, result; + int npoi=0; + int opt_first_sector_val = atoi(opt_first_sector); + int opt_first_sector_val = atoi(opt_first_sector); + int opt_last_sector_val = atoi(opt_last_sector); + int opt_last_sector_val = atoi(opt_last_sector); + int override = atoi(opt_gps_utc_offset); + int plen, ilen; + int poi = 0; + int rc, got_bytes; + int rc, timeout, i; + int rc; + int rc; + int read_at_once = MAX(atoi(opt_read_at_once), 1); + int res = 0; + int sectors_read; + int16_t dx; + int16_t dy; + int16_t dz; + int32_t alt; + int32_t lat; + int32_t lon; + int32_t x; + int32_t y; + int32_t z; + lalt=alt; + le_write_double(&MSG_SET_LOCATION[1], lat); + le_write_double(&MSG_SET_LOCATION[9], lng); + llat=lat*M_PI/180; + llng=lng*M_PI/180; + long double a = 6378137.0; + long double esqr = 6.69437999014e-3; + long double llat, llng, lalt; + long double n; + long double s; + long x, y, z; + mhport.clear(); + mhport=fname; + miniHomer_args, + miniHomer_rd_deinit, + miniHomer_rd_init, + miniHomer_read, + multi_hz_item m; + n = a / sqrt(1 - esqr * s*s); + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + nullptr + nullptr + opt_set_location=NULL; // otherwise it will lead to bus error + printf("len=%i skytraq_baud=%i timeout=%i\n", len, skytraq_baud, timeout);*/ + pst->gps_sec = 0; + pst->gps_week = 0; + pst->route_head_ = track; + pst->tpn = 0; + pst->wpn = 0; + pst->x = 0; + pst->y = 0; + pst->z = 0; + rc = gbser_read_wait(serial_handle, (void*)buf, len, timeout); + rc = skytraq_expect_msg(0x94, (uint8_t*)&MSG_LOG_STATUS_OUTPUT, sizeof(MSG_LOG_STATUS_OUTPUT)); + rc = skytraq_wr_msg_verify(MSG_CONFIGURE_SERIAL_PORT, sizeof(MSG_CONFIGURE_SERIAL_PORT)); + rcv_cs = rd_char(&errors); + rd_buf((const unsigned char*) payload, MIN(rcv_len, len)); + rd_buf(buf+SECTOR_SIZE*sector_count, sizeof(SECTOR_READ_END)+6); + rd_char(&errors); + rd_char(&errors); + rd_char(&errors); + rd_char(&errors); + rd_char(&errors); + rd_char(&errors); + rd_drain(); + rd_drain(); + read_result = skytraq_wr_msg_verify((uint8_t*)&MSG_LOG_READ_MULTI_SECTORS, sizeof(MSG_LOG_READ_MULTI_SECTORS)); + result=0; // result will be 0 if opt_poi isn't set + return ((unsigned)be_read16(p+2) << 16) | ((unsigned)be_read16(p)); + return (buffer[0] << 8) | buffer[1]; + return -1; + return -1; + return cs; + return gps_timet; /* returns UTC time */ + return plen; + return res; + return res_ERROR; + return res_NOTFOUND; + return res_OK; + return res_OK; + return res_OK; + return res_OK; + return res_OK; + return res_OK; + return res_OK; + return res_PROTOCOL_ERR; + return res_PROTOCOL_ERR; + return result; + return skytraq_wr_msg_verify(MSG_LOG_CONFIGURE_CONTROL, sizeof(MSG_LOG_CONFIGURE_CONTROL)); + return skytraq_wr_msg_verify(MSG_SYSTEM_RESTART, sizeof(MSG_SYSTEM_RESTART)); + return wpt; + route_head* route_head_; + route_head* track; + s=sin(llat); + sectors_read = 0; + serial_handle = NULL; + signed int rcv_len; + skytraq_args, + skytraq_fargs, + skytraq_rd_deinit(); + skytraq_rd_deinit, + skytraq_rd_init(fname); // sets global var serial_handle + skytraq_rd_init, + skytraq_read, + skytraq_set_baud(atoi(opt_dlbaud)); + skytraq_system_restart(); + sscanf(opt_set_location, "%lf:%lf", &lat, &lng); + state_init(&st); + state_init(&st); + struct read_state st; + struct read_state st; + struct { + struct { + switch (baud) { + switch (ITEM_TYPE(pitem)) { + time_t gps_timet = 315964800; /* Jan 06 1980 0:00 UTC */ + timeout = TIMEOUT + len;//*1000/(skytraq_baud/10); + tmax = le_readu32(&MSG_LOG_STATUS_OUTPUT.max_time); + tmin = le_readu32(&MSG_LOG_STATUS_OUTPUT.min_time); + track = route_head_alloc(); + track->rte_desc = "SkyTraq GPS tracklog data"; + track->rte_name = "SkyTraq tracklog"; + track_add_head(track); + uint16_t dt; + uint16_t sectors_free, sectors_total, /*sectors_used_a, sectors_used_b,*/ sectors_used; + uint32_t gps_sec; + uint32_t gps_sec; + uint32_t gps_week; + uint32_t gps_week; + uint32_t log_wr_ptr; + uint8_t ack_msg[2]; + uint8_t buf[32]; + uint8_t buffer[16]; + uint8_t buffer[2]; + uint8_t MSG_CONFIGURE_SERIAL_PORT[4] + uint8_t MSG_GET_LOCATION = 0x35; + uint8_t MSG_GET_POI[3] = { 0x4D, 0, 0}; + uint8_t MSG_LOG_CONFIGURE_CONTROL[] = { + uint8_t MSG_LOG_ERASE = 0x19; + uint8_t MSG_LOG_READ_MULTI_SECTORS[5] = { 0x1D }; + uint8_t MSG_LOG_SECTOR_READ_CONTROL[2] = { 0x1B, (uint8_t)(sector) }; + uint8_t MSG_LOG_STATUS_CONTROL = 0x17; + uint8_t MSG_QUERY_SOFTWARE_VERSION[2] = { 0x02, 0x01 }; + uint8_t MSG_SET_LOCATION[17] = { 0x36, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + uint8_t MSG_SET_POI[MSG_SET_POI_SIZE] = { + uint8_t MSG_SYSTEM_RESTART[15] = + uint8_t* buf_end_tag; + uint8_t* buffer = NULL; + uint8_t* buffer; + union { + unsigned wpn, tpn; + unsigned char alt[4]; + unsigned char dpos[4]; + unsigned char dt[2]; /* big endian unsigned short */ + unsigned char lat[4]; + unsigned char lon[4]; + unsigned char ts[4]; + unsigned char ts[4]; + unsigned char type_and_speed[2]; + unsigned char v_kmh[2]; + unsigned char x[4]; + unsigned char y[4]; + unsigned char z[4]; + unsigned gps_sec; + unsigned gps_week; + unsigned int c, i, j, cs; + unsigned int c, i, state; + unsigned int calc_cs, rcv_cs; + unsigned int cs, i, read_result; + unsigned int i; + unsigned int i; + unsigned int poi; + unsigned int rc; + unsigned int tmax, tmin, dmax, dmin, vmax, vmin; + unsigned int tmin=6, tmax=3600, dmin=0, dmax=10000, nn=0; + unsigned int ts; + va_end(ap); + va_list ap; + va_start(ap, msg); + vmax = le_readu32(&MSG_LOG_STATUS_OUTPUT.max_speed); + vmin = le_readu32(&MSG_LOG_STATUS_OUTPUT.min_speed); + Waypoint* tpt = NULL; + Waypoint* wpt = new Waypoint; + Waypoint* wpt; + while ((got_bytes = gbfread(buffer, 1, SECTOR_SIZE, file_handle)) > 0) { + while (*errors > 0) { + wpt->altitude = alt; + wpt->latitude = lat; + wpt->longitude = lon; + wpt->SetCreationTime(gpstime_to_timet(st->gps_week, st->gps_sec)); + wpt->shortname = QString().sprintf("TP%04d", ++st->tpn); + wr_buf(MSG_START, sizeof(MSG_START)); + wr_buf(NL, sizeof(NL)); + wr_buf(payload, len); + wr_char((len>>8) & 0x0FF); + wr_char(cs); + wr_char(len & 0x0FF); + xasprintf(&mystatus, "#logging: tmin=%u, tmax=%u, dmin=%u, dmax=%u, vmin=%u, vmax=%u\n", tmin, tmax, dmin, dmax, vmin, vmax); + xfree(buffer); + xfree(mystatus); + { + { + { + { + { + { + { + { + { + { + { + { + { + { + { + { + { + { + { "Bar", &opt_set_poi_bar, "POI for Bar Symbol as lat:lng[:alt]", NULL, ARGTYPE_STRING, "", "", nullptr }, + { "baud", &opt_dlbaud, "Baud rate used for download", "115200", ARGTYPE_INT, "0", "115200", nullptr }, + { "Boat", &opt_set_poi_boat, "POI for Boat Symbol as lat:lng[:alt]", NULL, ARGTYPE_STRING, "", "", nullptr }, + { "Car", &opt_set_poi_car, "POI for Car Symbol as lat:lng[:alt]", NULL, ARGTYPE_STRING, "", "", nullptr }, + { "dump-file", &opt_dump_file, "Dump raw data to this file", NULL, ARGTYPE_OUTFILE, ARG_NOMINMAX , nullptr}, + { "erase", &opt_erase, "Erase device data after download", "0", ARGTYPE_BOOL, ARG_NOMINMAX, nullptr }, + { "first-sector", &opt_first_sector, "First sector to be read from the device", "0", ARGTYPE_INT, "0", "65535", nullptr }, + { "Heart", &opt_set_poi_heart, "POI for Heart Symbol as lat:lng[:alt]", NULL, ARGTYPE_STRING, "", "" , nullptr}, + { "Home", &opt_set_poi_home, "POI for Home Symbol as lat:lng[:alt]", NULL, ARGTYPE_STRING, "", "", nullptr }, + { "initbaud", &opt_initbaud, "Baud rate used to init device (0=autodetect)", "38400", ARGTYPE_INT, "38400", "38400", nullptr }, + { "last-sector", &opt_last_sector, "Last sector to be read from the device (-1: smart read everything)", "-1", ARGTYPE_INT, "-1", "65535", nullptr }, + { "no-output", &opt_no_output, "Disable output (useful with erase)", "0", ARGTYPE_BOOL, ARG_NOMINMAX, nullptr }, + { "read-at-once", &opt_read_at_once, "Number of sectors to read at once (0=use single sector mode)", "255", ARGTYPE_INT, "0", "255", nullptr }, + { 0x01, 0x01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } else if (rc < len) { + } else { + } else { + } MSG_LOG_STATUS_OUTPUT; + } MSG_SOFTWARE_VERSION; + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }; + }; + }; + * the number of the POI will not be checked - if it is not correct, miniHome will send NACK + * -1 in case of errors + * 0 if opt_poi was not set + * 1 if poi was set + * 2010-10-23 Josef Reisinger + * http://navin.com.tw/miniHomer.htm + * Names of the POIs on miniHomer + * returns + * set lla (lat/lng/alt) specified as :[:type_and_speed[1] | ((item->type_and_speed[0] & 0x0F) << 8)) +#define ITEM_TYPE(item) (item->type_and_speed[0] >> 4) +#define ITEM_WEEK_NUMBER(item) (item->type_and_speed[1] | ((item->type_and_speed[0] & 0x03) << 8)) +#define MAX(X,Y) ((X) > (Y) ? (X) : (Y)) +#define MIN(X,Y) ((X) < (Y) ? (X) : (Y)) +#define MSG_RETRIES 3 +#define MSG_SET_POI_SIZE (sizeof(uint8_t)+sizeof(uint16_t)+3*sizeof(double)+sizeof(uint8_t)) +#define MULTI_HZ_ITEM_LEN 20 +#define MYNAME "miniHomer" +#define MYNAME "skytraq" +#define NUMPOI (sizeof poinames/sizeof poinames[0]) +#define POW_2_M20 0.000000953674316 +#define POW_2_M7 0.0078125 +#define res_ERROR -1 +#define res_NACK -2 +#define res_NOTFOUND -4 +#define res_OK 0 +#define res_PROTOCOL_ERR -3 +#define RETRIES 250 +#define SECTOR_RETRIES 3 +#define SECTOR_SIZE 4096 +#define SETPOI(poinum, poiname) if (opt_set_poi_##poiname ) {miniHomer_set_poi(poinum, opt_set_poi_##poiname);} +#define TIMEOUT 5000 +#else +#endif +#endif +#endif +#ifdef MYNAME +#ifdef READ_SINGLE_CHARS +#ifdef SINGLE_READ_WORKAROUND +#include "defs.h" +#include "gbser.h" +#include +#include +#include +#undef MYNAME +* %%% global callbacks called by gpsbabel main process %%% * +* %%% SkyTraq protocol implementation %%% * +*******************************************************************************/ +*******************************************************************************/ +/* +/* +/* +/* +/* Abort when reading a specific sector fails this many times: */ +/* Maximum number of chars to skip while waiting for a reply: */ +/* Maximum number of messages to read while expecting a specific message or ACK/NACK: */ +/* Note: the buffer is being padded with 0xFFs if necessary so there are always SECTOR_SIZE valid bytes */ +/* reads 32-bit "middle-endian" fields */ +/******************************************************************************* +/******************************************************************************* +/**************************************************************************/ +/**************************************************************************/ +// GPS_Math_XYZ_To_WGS84LatLonH(&lat, &lon, &alt, pst->x, pst->y, pst->z); +// if (rcv_len == sizeof(ack_msg)) { +// rcv_len = skytraq_rd_msg(ack_msg, sizeof(ack_msg)); +// return MIN(rcv_len, len); +// Algorith taken from these sources: +// capabilities below means: we can only read tracks +// Convert lla (lat, lng, alt) to ECEF +// http://earth-info.nga.mil/GandG/publications/tr8350.2/wgs84fin.pdf +// http://en.wikipedia.org/wiki/Geodetic_system#From_ECEF_to_geodetic +// http://www.mathworks.com/matlabcentral/fileexchange/7942-covert-lat-lon-alt-to-ecef-cartesian +//#define SINGLE_READ_WORKAROUND +arglist_t miniHomer_args[] = { +arglist_t skytraq_args[] = { +arglist_t skytraq_fargs[] = { +db(int l, const char* msg, ...) +ECEF_to_LLA(double x, double y, long z, double* lat, double* lon, double* alt) +ff_vecs_t miniHomer_vecs = { +ff_vecs_t skytraq_fvecs = { +ff_vecs_t skytraq_vecs = { +file_deinit(void) +file_init(const QString& fname) +file_read(void) +gpstime_to_timet(int week, int sec) +int getPoiByName(char* name) +make_trackpoint(struct read_state* st, double lat, double lon, double alt) +miniHomer_rd_deinit(void) +miniHomer_rd_init(const QString& fname) +miniHomer_read(void) +process_data_item(struct read_state* pst, const item_frame* pitem, int len) +process_data_sector(struct read_state* pst, const uint8_t* buf, int len) +rd_buf(const uint8_t* buf, int len) +rd_char(int* errors) +rd_drain(void) +rd_word(void) +skytraq_calc_checksum(const unsigned char* buf, int len) +skytraq_configure_logging(void) +skytraq_erase() +skytraq_expect_ack(uint8_t id) +skytraq_expect_msg(uint8_t id, const uint8_t* payload, int len) +skytraq_get_log_buffer_status(uint32_t* log_wr_ptr, uint16_t* sectors_free, uint16_t* sectors_total) +skytraq_probe(void) +skytraq_rd_deinit(void) +skytraq_rd_init(const QString& fname) +skytraq_rd_msg(const void* payload, unsigned int len) +skytraq_read(void) +skytraq_read_multiple_sectors(int first_sector, unsigned int sector_count, uint8_t* buf) +skytraq_read_single_sector(unsigned int sector, uint8_t* buf) +skytraq_read_tracks(void) +skytraq_set_baud(int baud) +skytraq_set_location(void) +skytraq_system_restart(void) +skytraq_wr_msg(const uint8_t* payload, int len) +skytraq_wr_msg_verify(const uint8_t* payload, int len) +state_init(struct read_state* pst) +static +static +static char* opt_configure_logging = 0; +static char* opt_dlbaud = 0; /* baud rate used for downloading tracks */ +static char* opt_dump_file = 0; /* dump raw data to this file (optional) */ +static char* opt_erase = 0; /* erase after read? (0/1) */ +static char* opt_first_sector = 0; /* first sector to be read from the device (default: 0) */ +static char* opt_gps_utc_offset = 0; +static char* opt_initbaud = 0; /* baud rate used to init device */ +static char* opt_last_sector = 0; /* last sector to be read from the device (default: smart read everything) */ +static char* opt_no_output = 0; /* disable output? (0/1) */ +static char* opt_read_at_once = 0; /* number of sectors to read at once (Venus6 only) */ +static char* opt_set_location = 0; /* set if the "targetlocation" options was used */ +static char* opt_set_poi_bar = NULL; /* set if a "poi" option was used */ +static char* opt_set_poi_boat = NULL; /* set if a "poi" option was used */ +static char* opt_set_poi_car = NULL; /* set if a "poi" option was used */ +static char* opt_set_poi_heart = NULL; /* set if a "poi" option was used */ +static char* opt_set_poi_home = NULL; /* set if a "poi" option was used */ +static const char* poinames[] = { +static gbfile* file_handle = 0; /* file descriptor (used by skytraq-bin format) */ +static int +static int +static int +static int +static int +static int +static int +static int +static int +static int +static int +static int +static int +static int +static int +static int +static int /* returns number of bytes processed (terminates on 0xFF i.e. empty or padding bytes) */ +static int miniHomer_set_poi(uint16_t poinum, const char* opt_poi) +static int skytraq_baud = 0; /* detected baud rate */ static QString mhport; +static time_t +static unsigned int +static unsigned int me_read32(const unsigned char* p) static void -miniHomer_rd_init(const QString& fname) -{ - opt_set_location=NULL; // otherwise it will lead to bus error - skytraq_rd_init(fname); // sets global var serial_handle - mhport=fname; -} static void -miniHomer_rd_deinit(void) -{ - skytraq_rd_deinit(); - mhport.clear(); -} -#define SETPOI(poinum, poiname) if (opt_set_poi_##poiname ) {miniHomer_set_poi(poinum, opt_set_poi_##poiname);} static void -miniHomer_read(void) +static void +static void +static void +static void +static void +static void +static void +static void +static void +static void +static void +static void +static void +static void +static void +static void miniHomer_get_poi() +static void* serial_handle = 0; /* IO file descriptor */ +static Waypoint* +struct compact_item_frame { +struct full_item_frame { +struct multi_hz_item_frame { +struct read_state { +typedef struct { +typedef struct { +typedef struct { +typedef struct { +uint8_t MSG_START[2] = { 0xA0, 0xA1 }; +uint8_t NL[2] = { 0x0D, 0x0A }; +uint8_t SECTOR_READ_END[13] = { 'E','N','D', 0, 'C','H','E','C','K','S','U','M','=' }; +void lla2ecef(double lat, double lng, double alt, double* ecef_x, double* ecef_y, double* ecef_z) +wr_buf(const unsigned char* str, int len) +wr_char(int c) +{ +{ +{ +{ +{ +{ +{ +{ +{ +{ +{ +{ +{ +{ +{ +{ +{ +{ +{ +{ +{ +{ +{ +{ +{ +{ +{ +{ +{ +{ +{ +{ +{ +{ +{ +{ +{ +{ +{ +{ +{ +{ { - int npoi=0; - /* - * read tracks and POI from miniHomer - */ - if (miniHomer_set_poi(0, opt_set_poi_home) > 0) { - npoi++; - } - if (miniHomer_set_poi(1, opt_set_poi_car) > 0) { - npoi++; - } - if (miniHomer_set_poi(2, opt_set_poi_boat) > 0) { - npoi++; - } - if (miniHomer_set_poi(3, opt_set_poi_heart) > 0) { - npoi++; - } - if (miniHomer_set_poi(4, opt_set_poi_bar) > 0) { - npoi++; - } - if (npoi == 0) { // do not read if POIs are set (consider set & read distinct operations) - skytraq_read(); // first read tracks (if not supressed by cmd line params) - // we need this call it initialized waypoint list etc... - skytraq_rd_deinit(); // skytraq_read called system_reset, which changes the baud rate. - - skytraq_rd_init(mhport); // Lets start from scratch and re-init the port - miniHomer_get_poi(); // add POI as waypoints to the waypoints of the track - } } - -ff_vecs_t miniHomer_vecs = { - ff_type_serial, - { - ff_cap_read /* waypoints */, - ff_cap_read /* tracks */, - ff_cap_none /* routes */ - }, - miniHomer_rd_init, - NULL, - miniHomer_rd_deinit, - NULL, - miniHomer_read, - NULL, - NULL, - miniHomer_args, - CET_CHARSET_UTF8, 1 /* master process: don't convert anything */ - +} +} +} +} +} +} +} +} +} +} +} +} +} +} +} +} +} +} +} +} +} +} +} +} +} +} +} +} +} +} +} +} +} +} +} +} +} +} +} +} +} +} +} compact_item; +} full_item; +} item_frame; +} multi_hz_item; +}; +}; +}; +}; +}; +}; +}; +}; +}; }; +}; \ No newline at end of file diff --git a/smplrout.cc b/smplrout.cc index ef0659e24..0d28ac8e1 100644 --- a/smplrout.cc +++ b/smplrout.cc @@ -80,23 +80,23 @@ static arglist_t routesimple_args[] = { { "count", &countopt, "Maximum number of points in route", - NULL, ARGTYPE_INT | ARGTYPE_BEGIN_REQ | ARGTYPE_BEGIN_EXCL, "1", NULL + NULL, ARGTYPE_INT | ARGTYPE_BEGIN_REQ | ARGTYPE_BEGIN_EXCL, "1", NULL, nullptr }, { "error", &erroropt, "Maximum error", NULL, - ARGTYPE_STRING | ARGTYPE_END_REQ | ARGTYPE_END_EXCL, "0", NULL + ARGTYPE_STRING | ARGTYPE_END_REQ | ARGTYPE_END_EXCL, "0", NULL, nullptr }, { "crosstrack", &xteopt, "Use cross-track error (default)", NULL, - ARGTYPE_BOOL | ARGTYPE_BEGIN_EXCL, ARG_NOMINMAX + ARGTYPE_BOOL | ARGTYPE_BEGIN_EXCL, ARG_NOMINMAX, nullptr }, { "length", &lenopt, "Use arclength error", NULL, - ARGTYPE_BOOL, ARG_NOMINMAX + ARGTYPE_BOOL, ARG_NOMINMAX, nullptr }, { "relative", &relopt, "Use relative error", NULL, - ARGTYPE_BOOL | ARGTYPE_END_EXCL, ARG_NOMINMAX + ARGTYPE_BOOL | ARGTYPE_END_EXCL, ARG_NOMINMAX, nullptr }, ARG_TERMINATOR }; @@ -373,7 +373,7 @@ routesimple_tail(const route_head* rte) } void -routesimple_process(void) +routesimple_process() { waypt_del_fnp = route_del_wpt; route_disp_all(routesimple_head, routesimple_tail, routesimple_waypt_pr); @@ -383,7 +383,7 @@ routesimple_process(void) } void -routesimple_init(const char* args) +routesimple_init(const char*) { count = 0; @@ -411,7 +411,7 @@ routesimple_init(const char* args) } void -routesimple_deinit(void) +routesimple_deinit() { /* do nothing */ } diff --git a/sort.cc b/sort.cc index c1a497f2f..bff79f7a1 100644 --- a/sort.cc +++ b/sort.cc @@ -40,19 +40,19 @@ static arglist_t sort_args[] = { { "gcid", &opt_sm_gcid, "Sort by numeric geocache ID", - NULL, ARGTYPE_BOOL, ARG_NOMINMAX + NULL, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr }, { "shortname", &opt_sm_shortname, "Sort by waypoint short name", - NULL, ARGTYPE_BOOL, ARG_NOMINMAX + NULL, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr }, { "description", &opt_sm_description, "Sort by waypoint description", - NULL, ARGTYPE_BOOL, ARG_NOMINMAX + NULL, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr }, { "time", &opt_sm_time, "Sort by time", - NULL, ARGTYPE_BOOL, ARG_NOMINMAX + NULL, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr }, ARG_TERMINATOR }; @@ -79,13 +79,13 @@ sort_comp(const queue* a, const queue* b) } void -sort_process(void) +sort_process() { sortqueue(&waypt_head, sort_comp); } void -sort_init(const char* args) +sort_init(const char*) { if (opt_sm_gcid) { sort_mode = sm_gcid; diff --git a/stackfilter.cc b/stackfilter.cc index 303f94adc..54aa64529 100644 --- a/stackfilter.cc +++ b/stackfilter.cc @@ -43,39 +43,39 @@ static arglist_t stackfilt_args[] = { { "push", &opt_push, "Push waypoint list onto stack", NULL, - ARGTYPE_BEGIN_EXCL | ARGTYPE_BEGIN_REQ | ARGTYPE_BOOL, ARG_NOMINMAX + ARGTYPE_BEGIN_EXCL | ARGTYPE_BEGIN_REQ | ARGTYPE_BOOL, ARG_NOMINMAX, nullptr }, { "pop", &opt_pop, "Pop waypoint list from stack", NULL, - ARGTYPE_BOOL, ARG_NOMINMAX + ARGTYPE_BOOL, ARG_NOMINMAX, nullptr }, { "swap", &opt_swap, "Swap waypoint list with item on stack", - NULL, ARGTYPE_END_EXCL | ARGTYPE_END_REQ | ARGTYPE_BOOL, ARG_NOMINMAX + NULL, ARGTYPE_END_EXCL | ARGTYPE_END_REQ | ARGTYPE_BOOL, ARG_NOMINMAX, nullptr }, { "copy", &opt_copy, "(push) Copy waypoint list", NULL, - ARGTYPE_BOOL, ARG_NOMINMAX + ARGTYPE_BOOL, ARG_NOMINMAX, nullptr }, { "append", &opt_append, "(pop) Append list", NULL, - ARGTYPE_BEGIN_EXCL | ARGTYPE_BOOL, ARG_NOMINMAX + ARGTYPE_BEGIN_EXCL | ARGTYPE_BOOL, ARG_NOMINMAX, nullptr }, { "discard", &opt_discard, "(pop) Discard top of stack", - NULL, ARGTYPE_BOOL, ARG_NOMINMAX + NULL, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr }, { "replace", &opt_replace, "(pop) Replace list (default)", - NULL, ARGTYPE_END_EXCL | ARGTYPE_BOOL, ARG_NOMINMAX + NULL, ARGTYPE_END_EXCL | ARGTYPE_BOOL, ARG_NOMINMAX, nullptr }, { "depth", &opt_depth, "(swap) Item to use (default=1)", - NULL, ARGTYPE_INT, "0", NULL + NULL, ARGTYPE_INT, "0", NULL, nullptr }, { "nowarn", &nowarn, "Suppress cleanup warning", NULL, - ARGTYPE_BOOL | ARGTYPE_HIDDEN, ARG_NOMINMAX + ARGTYPE_BOOL | ARGTYPE_HIDDEN, ARG_NOMINMAX, nullptr }, ARG_TERMINATOR }; @@ -92,7 +92,7 @@ struct stack_elt { void -stackfilt_process(void) +stackfilt_process() { struct stack_elt* tmp_elt = NULL; queue* elem = NULL; @@ -192,7 +192,7 @@ stackfilt_process(void) } void -stackfilt_init(const char* args) +stackfilt_init(const char*) { int invalid = 0; @@ -232,13 +232,13 @@ stackfilt_init(const char* args) } void -stackfilt_deinit(void) +stackfilt_deinit() { swapdepth = 0; } void -stackfilt_exit(void) +stackfilt_exit() { struct stack_elt* tmp_elt = NULL; diff --git a/stmsdf.cc b/stmsdf.cc index b94f9dcbd..69c777262 100644 --- a/stmsdf.cc +++ b/stmsdf.cc @@ -95,7 +95,7 @@ static arglist_t stmsdf_args[] = { { "index", &opt_route_index, - "Index of route (if more than one in source)", "1", ARGTYPE_INT, "1", NULL + "Index of route (if more than one in source)", "1", ARGTYPE_INT, "1", NULL, nullptr }, ARG_TERMINATOR }; @@ -548,7 +548,7 @@ any_waypt_calc_cb(const Waypoint* wpt) } static void -any_tlr_calc_cb(const route_head* trk) +any_tlr_calc_cb(const route_head*) { if (! this_valid) { return; @@ -634,13 +634,13 @@ track_disp_wpt_cb(const Waypoint* wpt) } static void -track_disp_tlr_cb(const route_head* rte) +track_disp_tlr_cb(const route_head*) { trkpt_out = NULL; } static void -route_disp_hdr_cb(const route_head* rte) +route_disp_hdr_cb(const route_head*) { route_index++; this_route_valid = ((opt_route_index_value < 1) || (opt_route_index_value == track_index)); @@ -805,6 +805,8 @@ ff_vecs_t stmsdf_vecs = { NULL, stmsdf_args, CET_CHARSET_MS_ANSI, 0 /* CET-REVIEW */ + , NULL_POS_OPS, + nullptr }; /* ================================================================== */ diff --git a/stmwpp.cc b/stmwpp.cc index fcc333677..8f9a37cc5 100644 --- a/stmwpp.cc +++ b/stmwpp.cc @@ -53,7 +53,7 @@ static arglist_t stmwpp_args[] = { { "index", &index_opt, "Index of route/track to write (if more than one in source)", - NULL, ARGTYPE_INT, "1", NULL + NULL, ARGTYPE_INT, "1", NULL, nullptr }, ARG_TERMINATOR }; @@ -208,7 +208,7 @@ stmwpp_rw_deinit(void) } static void -stmwpp_track_hdr(const route_head* track) +stmwpp_track_hdr(const route_head*) { track_num++; } @@ -333,6 +333,8 @@ ff_vecs_t stmwpp_vecs = { NULL, stmwpp_args, CET_CHARSET_MS_ANSI, 0 + , NULL_POS_OPS, + nullptr }; #endif /* CSVFMTS_ENABLED */ diff --git a/subrip.cc b/subrip.cc index 60e890212..41c377cf5 100644 --- a/subrip.cc +++ b/subrip.cc @@ -264,10 +264,10 @@ subrip_write(void) arglist_t subrip_args[] = { // FIXME: document that gps_date and gps_time must be specified together or they will both be ignored and the timestamp of the first trackpoint will be used. - {"video_time", &opt_videotime, "Video position for which exact GPS time is known (hhmmss, default is 0:00:00)", 0, ARGTYPE_STRING, ARG_NOMINMAX }, - {"gps_time", &opt_gpstime, "GPS time at position video_time (hhmmss, default is first timestamp of track)", 0, ARGTYPE_STRING, ARG_NOMINMAX }, - {"gps_date", &opt_gpsdate, "GPS date at position video_time (hhmmss, default is first timestamp of track)", 0, ARGTYPE_STRING, ARG_NOMINMAX }, - {"format", &opt_format, "Format for subtitles", "%s km/h %e m\\n%t %l", ARGTYPE_STRING, ARG_NOMINMAX }, + {"video_time", &opt_videotime, "Video position for which exact GPS time is known (hhmmss, default is 0:00:00)", 0, ARGTYPE_STRING, ARG_NOMINMAX, nullptr }, + {"gps_time", &opt_gpstime, "GPS time at position video_time (hhmmss, default is first timestamp of track)", 0, ARGTYPE_STRING, ARG_NOMINMAX, nullptr }, + {"gps_date", &opt_gpsdate, "GPS date at position video_time (hhmmss, default is first timestamp of track)", 0, ARGTYPE_STRING, ARG_NOMINMAX, nullptr }, + {"format", &opt_format, "Format for subtitles", "%s km/h %e m\\n%t %l", ARGTYPE_STRING, ARG_NOMINMAX, nullptr }, ARG_TERMINATOR }; @@ -285,4 +285,6 @@ ff_vecs_t subrip_vecs = { NULL, subrip_args, CET_CHARSET_ASCII, 0 + , NULL_POS_OPS, + nullptr }; diff --git a/tef_xml.cc b/tef_xml.cc index 37dd85ba7..5149dba9d 100644 --- a/tef_xml.cc +++ b/tef_xml.cc @@ -39,7 +39,7 @@ static char* routevia = NULL; static arglist_t tef_xml_args[] = { { "routevia", &routevia, "Include only via stations in route", - NULL, ARGTYPE_BOOL, ARG_NOMINMAX + NULL, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr }, ARG_TERMINATOR }; @@ -67,7 +67,7 @@ xg_tag_mapping tef_xml_map[] = { */ void -tef_start(xg_string args, const QXmlStreamAttributes* attrv) +tef_start(xg_string, const QXmlStreamAttributes* attrv) { bool valid = false; @@ -91,7 +91,7 @@ tef_start(xg_string args, const QXmlStreamAttributes* attrv) */ static void -tef_header(xg_string args, const QXmlStreamAttributes* attrv) +tef_header(xg_string, const QXmlStreamAttributes* attrv) { route = route_head_alloc(); foreach(QXmlStreamAttribute attr, *attrv) { @@ -105,7 +105,7 @@ tef_header(xg_string args, const QXmlStreamAttributes* attrv) } static void -tef_list_start(xg_string args, const QXmlStreamAttributes* attrv) +tef_list_start(xg_string, const QXmlStreamAttributes* attrv) { if (attrv->hasAttribute("ItemCount")) { item_count = attrv->value("ItemCount").toString().toUInt(); @@ -178,7 +178,7 @@ Xfix_notes(const QString& name, const QString& notes) } #else static QString -fix_notes(const QString& name, const QString& notes){ +fix_notes(const QString&, const QString& notes){ return notes; } #endif @@ -220,13 +220,13 @@ waypoint_final() } static void -tef_item_end(xg_string args, const QXmlStreamAttributes*) +tef_item_end(xg_string, const QXmlStreamAttributes*) { waypoint_final(); } static void -tef_list_end(xg_string args, const QXmlStreamAttributes*) +tef_list_end(xg_string, const QXmlStreamAttributes*) { waypoint_final(); if (waypoints != item_count) @@ -235,7 +235,7 @@ tef_list_end(xg_string args, const QXmlStreamAttributes*) } static void -tef_item_start(xg_string args, const QXmlStreamAttributes* attrv) +tef_item_start(xg_string, const QXmlStreamAttributes* attrv) { waypoints++; @@ -283,7 +283,7 @@ tef_read_comma_float(const QStringRef& value) } static void -tef_point(xg_string args, const QXmlStreamAttributes* attrv) +tef_point(xg_string, const QXmlStreamAttributes* attrv) { if (!wpt_tmp) { return; @@ -333,4 +333,6 @@ ff_vecs_t tef_xml_vecs = { NULL, tef_xml_args, CET_CHARSET_UTF8, 1 + , NULL_POS_OPS, + nullptr }; diff --git a/teletype.cc b/teletype.cc index f25a26b08..0c4fc47a5 100644 --- a/teletype.cc +++ b/teletype.cc @@ -117,5 +117,7 @@ ff_vecs_t teletype_vecs = { teletype_args, CET_CHARSET_ASCII, 0 /* ascii is the expected character set */ /* not fixed, can be changed through command line parameter */ + , NULL_POS_OPS, + nullptr }; /**************************************************************************/ diff --git a/text.cc b/text.cc index ab40eee17..a345b34db 100644 --- a/text.cc +++ b/text.cc @@ -45,27 +45,27 @@ arglist_t text_args[] = { { "nosep", &suppresssep, "Suppress separator lines between waypoints", - NULL, ARGTYPE_BOOL, ARG_NOMINMAX + NULL, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr }, { "encrypt", &txt_encrypt, - "Encrypt hints using ROT13", NULL, ARGTYPE_BOOL, ARG_NOMINMAX + "Encrypt hints using ROT13", NULL, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr }, { "logs", &includelogs, - "Include groundspeak logs if present", NULL, ARGTYPE_BOOL, ARG_NOMINMAX + "Include groundspeak logs if present", NULL, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr }, { "degformat", °format, - "Degrees output as 'ddd', 'dmm'(default) or 'dms'", "dmm", ARGTYPE_STRING, ARG_NOMINMAX + "Degrees output as 'ddd', 'dmm'(default) or 'dms'", "dmm", ARGTYPE_STRING, ARG_NOMINMAX, nullptr }, { "altunits", &altunits, - "Units for altitude (f)eet or (m)etres", "m", ARGTYPE_STRING, ARG_NOMINMAX + "Units for altitude (f)eet or (m)etres", "m", ARGTYPE_STRING, ARG_NOMINMAX, nullptr }, { "splitoutput", &split_output, - "Write each waypoint in a separate file", NULL, ARGTYPE_BOOL, ARG_NOMINMAX + "Write each waypoint in a separate file", NULL, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr }, ARG_TERMINATOR @@ -281,5 +281,7 @@ ff_vecs_t text_vecs = { NULL, text_args, CET_CHARSET_ASCII, 0 /* CET-REVIEW */ + , NULL_POS_OPS, + nullptr }; diff --git a/tiger.cc b/tiger.cc index 6d1e2d64e..6631bfc3d 100644 --- a/tiger.cc +++ b/tiger.cc @@ -66,59 +66,59 @@ static arglist_t tiger_args[] = { { "nolabels", &nolabels, "Suppress labels on generated pins", - NULL, ARGTYPE_BOOL, ARG_NOMINMAX + NULL, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr }, { "genurl", &genurl, "Generate file with lat/lon for centering map", - NULL, ARGTYPE_OUTFILE, ARG_NOMINMAX + NULL, ARGTYPE_OUTFILE, ARG_NOMINMAX, nullptr }, { "margin", &margin, "Margin for map. Degrees or percentage", - "15%", ARGTYPE_FLOAT, ARG_NOMINMAX + "15%", ARGTYPE_FLOAT, ARG_NOMINMAX, nullptr }, { "snlen", &snlen, "Max shortname length when used with -s", - "10", ARGTYPE_INT, "1", NULL + "10", ARGTYPE_INT, "1", NULL, nullptr }, { "oldthresh", &oldthresh, "Days after which points are considered old", - "14", ARGTYPE_INT, ARG_NOMINMAX + "14", ARGTYPE_INT, ARG_NOMINMAX, nullptr }, { "oldmarker", &oldmarker, "Marker type for old points", - "redpin", ARGTYPE_STRING, ARG_NOMINMAX + "redpin", ARGTYPE_STRING, ARG_NOMINMAX, nullptr }, { "newmarker", &newmarker, "Marker type for new points", - "greenpin", ARGTYPE_STRING, ARG_NOMINMAX + "greenpin", ARGTYPE_STRING, ARG_NOMINMAX, nullptr }, { "suppresswhite", &suppresswhite, "Suppress whitespace in generated shortnames", - NULL, ARGTYPE_BOOL, ARG_NOMINMAX + NULL, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr }, { "unfoundmarker", &unfoundmarker, "Marker type for unfound points", - "bluepin", ARGTYPE_STRING, ARG_NOMINMAX + "bluepin", ARGTYPE_STRING, ARG_NOMINMAX, nullptr }, { "xpixels", &xpixels, "Width in pixels of map", - "768", ARGTYPE_INT, ARG_NOMINMAX + "768", ARGTYPE_INT, ARG_NOMINMAX, nullptr }, { "ypixels", &ypixels, "Height in pixels of map", - "768", ARGTYPE_INT, ARG_NOMINMAX + "768", ARGTYPE_INT, ARG_NOMINMAX, nullptr }, { "iconismarker", &iconismarker, "The icon description is already the marker", NULL, - ARGTYPE_BOOL, ARG_NOMINMAX + ARGTYPE_BOOL, ARG_NOMINMAX, nullptr }, #if CLICKMAP { "clickmap", &clickmap, "Generate Clickable map web page", - NULL, ARGTYPE_BOOL, ARG_NOMINMAX + NULL, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr }, #endif ARG_TERMINATOR @@ -329,4 +329,6 @@ ff_vecs_t tiger_vecs = { NULL, tiger_args, CET_CHARSET_ASCII, 0 /* CET-REVIEW */ + , NULL_POS_OPS, + nullptr }; diff --git a/tmpro.cc b/tmpro.cc index 083eb489d..4358705f6 100644 --- a/tmpro.cc +++ b/tmpro.cc @@ -258,5 +258,7 @@ ff_vecs_t tmpro_vecs = { NULL, NULL, CET_CHARSET_ASCII, 0 /* CET-REVIEW */ + , NULL_POS_OPS, + nullptr }; diff --git a/tomtom.cc b/tomtom.cc index 2ddc4309b..bcb7939f8 100644 --- a/tomtom.cc +++ b/tomtom.cc @@ -483,4 +483,6 @@ ff_vecs_t tomtom_vecs = { NULL, tomtom_args, CET_CHARSET_MS_ANSI, 0 /* CET-REVIEW */ + , NULL_POS_OPS, + nullptr }; diff --git a/tpg.cc b/tpg.cc index 8e710ba7a..5f9aca313 100644 --- a/tpg.cc +++ b/tpg.cc @@ -40,7 +40,7 @@ static unsigned int waypt_out_count; static arglist_t tpg_args[] = { - {"datum", &tpg_datum_opt, "Datum (default=NAD27)", "N. America 1927 mean", ARGTYPE_STRING, ARG_NOMINMAX }, + {"datum", &tpg_datum_opt, "Datum (default=NAD27)", "N. America 1927 mean", ARGTYPE_STRING, ARG_NOMINMAX , nullptr}, ARG_TERMINATOR }; @@ -322,4 +322,5 @@ ff_vecs_t tpg_vecs = { NULL, tpg_args, CET_CHARSET_ASCII, 0 /* CET-REVIEW */ -}; + , NULL_POS_OPS, + nullptr}; diff --git a/tpo.cc b/tpo.cc index fb9927991..7bc9c92f9 100644 --- a/tpo.cc +++ b/tpo.cc @@ -1813,7 +1813,7 @@ tpo_track_disp(const Waypoint* waypointp) } static void -tpo_track_tlr(const route_head* rte) +tpo_track_tlr(const route_head*) { unsigned char unknown1[] = { 0x06, 0x00 }; @@ -1897,6 +1897,8 @@ ff_vecs_t tpo2_vecs = { NULL, tpo2_args, CET_CHARSET_ASCII, 0 /* CET-REVIEW */ + , NULL_POS_OPS, + nullptr }; /* TPO 3.x format can read waypoints/tracks/routes */ @@ -1912,4 +1914,6 @@ ff_vecs_t tpo3_vecs = { NULL, tpo3_args, CET_CHARSET_ASCII, 0 /* CET-REVIEW */ + , NULL_POS_OPS, + nullptr }; diff --git a/trackfilter.cc b/trackfilter.cc index 9005f8903..2cc562ad3 100644 --- a/trackfilter.cc +++ b/trackfilter.cc @@ -80,90 +80,90 @@ arglist_t trackfilter_args[] = { { TRACKFILTER_MOVE_OPTION, &opt_move, "Correct trackpoint timestamps by a delta", NULL, ARGTYPE_STRING, - ARG_NOMINMAX + ARG_NOMINMAX, nullptr }, { TRACKFILTER_PACK_OPTION, &opt_pack, - "Pack all tracks into one", NULL, ARGTYPE_BOOL, ARG_NOMINMAX + "Pack all tracks into one", NULL, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr }, { TRACKFILTER_SPLIT_OPTION, &opt_split, "Split by date or time interval (see README)", NULL, - ARGTYPE_STRING, ARG_NOMINMAX + ARGTYPE_STRING, ARG_NOMINMAX, nullptr }, { TRACKFILTER_SDIST_OPTION, &opt_sdistance, "Split by distance", NULL, - ARGTYPE_STRING, ARG_NOMINMAX + ARGTYPE_STRING, ARG_NOMINMAX, nullptr }, { TRACKFILTER_MERGE_OPTION, &opt_merge, "Merge multiple tracks for the same way", NULL, ARGTYPE_STRING, - ARG_NOMINMAX + ARG_NOMINMAX, nullptr }, { TRACKFILTER_NAME_OPTION, &opt_name, "Use only track(s) where title matches given name", NULL, ARGTYPE_STRING, - ARG_NOMINMAX + ARG_NOMINMAX, nullptr }, { TRACKFILTER_START_OPTION, &opt_start, "Use only track points after this timestamp", NULL, ARGTYPE_INT, - ARG_NOMINMAX + ARG_NOMINMAX, nullptr }, { TRACKFILTER_STOP_OPTION, &opt_stop, "Use only track points before this timestamp", NULL, ARGTYPE_INT, - ARG_NOMINMAX + ARG_NOMINMAX, nullptr }, { TRACKFILTER_TITLE_OPTION, &opt_title, - "Basic title for new track(s)", NULL, ARGTYPE_STRING, ARG_NOMINMAX + "Basic title for new track(s)", NULL, ARGTYPE_STRING, ARG_NOMINMAX, nullptr }, { TRACKFILTER_FIX_OPTION, &opt_fix, "Synthesize GPS fixes (PPS, DGPS, 3D, 2D, NONE)", NULL, - ARGTYPE_STRING, ARG_NOMINMAX + ARGTYPE_STRING, ARG_NOMINMAX, nullptr }, { TRACKFILTER_COURSE_OPTION, &opt_course, "Synthesize course", - NULL, ARGTYPE_BOOL, ARG_NOMINMAX + NULL, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr }, { TRACKFILTER_SPEED_OPTION, &opt_speed, "Synthesize speed", - NULL, ARGTYPE_BOOL, ARG_NOMINMAX + NULL, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr }, { TRACKFILTER_SEG2TRK_OPTION, &opt_seg2trk, "Split track at segment boundaries into multiple tracks", - NULL, ARGTYPE_BOOL, ARG_NOMINMAX + NULL, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr }, { TRACKFILTER_TRK2SEG_OPTION, &opt_trk2seg, "Merge tracks inserting segment separators at boundaries", - NULL, ARGTYPE_BOOL, ARG_NOMINMAX + NULL, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr }, { TRACKFILTER_SEGMENT_OPTION, &opt_segment, "segment tracks with abnormally long gaps", - NULL, ARGTYPE_BOOL, ARG_NOMINMAX + NULL, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr }, { TRACKFILTER_FAKETIME_OPTION, &opt_faketime, "Add specified timestamp to each trackpoint", - NULL, ARGTYPE_STRING, ARG_NOMINMAX + NULL, ARGTYPE_STRING, ARG_NOMINMAX, nullptr }, { TRACKFILTER_DISCARD_OPTION, &opt_discard, "Discard track points without timestamps during merge", - NULL, ARGTYPE_BOOL, ARG_NOMINMAX + NULL, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr }, { TRACKFILTER_MINPOINTS_OPTION, &opt_minpoints, "Discard tracks with fewer than these points", - NULL, ARGTYPE_INT, "0" - }, - ARG_TERMINATOR + NULL, ARGTYPE_INT, "0", "50", nullptr + }//, + //ARG_TERMINATOR }; @@ -186,7 +186,7 @@ static char need_time; /* initialized within trackfilter_init */ *******************************************************************************/ static int -trackfilter_opt_count(void) +trackfilter_opt_count() { int res = 0; arglist_t* a = trackfilter_args; @@ -443,7 +443,7 @@ trackfilter_pack_init_rte_name(route_head* track, const time_t default_time) *******************************************************************************/ static void -trackfilter_title(void) +trackfilter_title() { int i; @@ -465,7 +465,7 @@ trackfilter_title(void) *******************************************************************************/ static void -trackfilter_pack(void) +trackfilter_pack() { int i, j; trkflt_t prev; @@ -504,7 +504,7 @@ trackfilter_pack(void) *******************************************************************************/ static void -trackfilter_merge(void) +trackfilter_merge() { int i, j, dropped; @@ -569,7 +569,7 @@ trackfilter_merge(void) *******************************************************************************/ static void -trackfilter_split(void) +trackfilter_split() { route_head* curr; route_head* master = track_list[0].track; @@ -770,7 +770,7 @@ trackfilter_split(void) *******************************************************************************/ static void -trackfilter_move(void) +trackfilter_move() { int i; queue* elem, *tmp; @@ -799,7 +799,7 @@ trackfilter_move(void) *******************************************************************************/ static void -trackfilter_synth(void) +trackfilter_synth() { int i; queue* elem, *tmp; @@ -895,7 +895,7 @@ trackfilter_range_check(const char* timestr) } static int -trackfilter_range(void) /* returns number of track points left after filtering */ +trackfilter_range() /* returns number of track points left after filtering */ { time_t start, stop; queue* elem, *tmp; @@ -954,7 +954,7 @@ trackfilter_range(void) /* returns number of track points left after filtering *******************************************************************************/ static void -trackfilter_seg2trk(void) +trackfilter_seg2trk() { int i; @@ -1004,7 +1004,7 @@ trackfilter_seg2trk(void) *******************************************************************************/ static void -trackfilter_trk2seg(void) +trackfilter_trk2seg() { int i, first; route_head* master; @@ -1104,7 +1104,7 @@ trackfilter_faketime_check(const char* timestr) } static int -trackfilter_faketime(void) /* returns number of track points left after filtering */ +trackfilter_faketime() /* returns number of track points left after filtering */ { faketime_t faketime; @@ -1207,7 +1207,7 @@ trackfilter_segment_head(const route_head* rte) *******************************************************************************/ static void -trackfilter_init(const char* args) +trackfilter_init(const char*) { int count = track_count(); @@ -1250,7 +1250,7 @@ trackfilter_init(const char* args) } static void -trackfilter_deinit(void) +trackfilter_deinit() { delete[] track_list; track_ct = 0; @@ -1262,7 +1262,7 @@ trackfilter_deinit(void) *******************************************************************************/ static void -trackfilter_process(void) +trackfilter_process() { int opts, something_done; diff --git a/transform.cc b/transform.cc index 1fa9b7de5..a53ce996b 100644 --- a/transform.cc +++ b/transform.cc @@ -45,33 +45,33 @@ static arglist_t transform_args[] = { { "wpt", &opt_waypts, "Transform track(s) or route(s) into waypoint(s) [R/T]", NULL, - ARGTYPE_STRING, ARG_NOMINMAX + ARGTYPE_STRING, ARG_NOMINMAX, nullptr }, { "rte", &opt_routes, "Transform waypoint(s) or track(s) into route(s) [W/T]", NULL, - ARGTYPE_STRING, ARG_NOMINMAX + ARGTYPE_STRING, ARG_NOMINMAX, nullptr }, { "trk", &opt_tracks, "Transform waypoint(s) or route(s) into tracks(s) [W/R]", NULL, - ARGTYPE_STRING, ARG_NOMINMAX + ARGTYPE_STRING, ARG_NOMINMAX, nullptr }, { "rptdigits", &rpt_name_digits, "Number of digits in generated names", NULL, - ARGTYPE_INT, "2", NULL + ARGTYPE_INT, "2", NULL, nullptr }, { "rptname", &opt_rpt_name, "Use source name for route point names", "N", - ARGTYPE_BOOL, ARG_NOMINMAX + ARGTYPE_BOOL, ARG_NOMINMAX, nullptr }, { "del", &opt_delete, "Delete source data after transformation", "N", - ARGTYPE_BOOL, ARG_NOMINMAX + ARGTYPE_BOOL, ARG_NOMINMAX, nullptr }, ARG_TERMINATOR }; static void -transform_waypoints(void) +transform_waypoints() { route_head* rte; @@ -153,13 +153,13 @@ transform_any_disp_wpt_cb(const Waypoint* wpt) } static void -transform_routes(void) +transform_routes() { route_disp_all(transform_rte_disp_hdr_cb, NULL, transform_any_disp_wpt_cb); } static void -transform_tracks(void) +transform_tracks() { track_disp_all(transform_trk_disp_hdr_cb, NULL, transform_any_disp_wpt_cb); } @@ -169,17 +169,17 @@ transform_tracks(void) *******************************************************************************/ static void -transform_init(const char* args) +transform_init(const char*) { } static void -transform_deinit(void) +transform_deinit() { } static void -transform_process(void) +transform_process() { int delete_after = (opt_delete && (*opt_delete == '1')) ? 1 : 0; diff --git a/unicsv.cc b/unicsv.cc index 6312e9d27..07d986b9c 100644 --- a/unicsv.cc +++ b/unicsv.cc @@ -264,31 +264,31 @@ static int llprec; static arglist_t unicsv_args[] = { { "datum", &opt_datum, "GPS datum (def. WGS 84)", - "WGS 84", ARGTYPE_STRING, ARG_NOMINMAX + "WGS 84", ARGTYPE_STRING, ARG_NOMINMAX, nullptr }, { "grid", &opt_grid, "Write position using this grid.", - NULL, ARGTYPE_STRING, ARG_NOMINMAX + NULL, ARGTYPE_STRING, ARG_NOMINMAX, nullptr }, { "utc", &opt_utc, "Write timestamps with offset x to UTC time", - NULL, ARGTYPE_INT, "-23", "+23" + NULL, ARGTYPE_INT, "-23", "+23", nullptr }, { "format", &opt_format, "Write name(s) of format(s) from input session(s)", - NULL, ARGTYPE_BOOL, ARG_NOMINMAX + NULL, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr }, { "filename", &opt_filename, "Write filename(s) from input session(s)", - NULL, ARGTYPE_BOOL, ARG_NOMINMAX + NULL, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr }, { "prec", &opt_prec, "Precision of numerical coordinates (no grid set)", - "6", ARGTYPE_INT | ARGTYPE_HIDDEN, "0", "15" + "6", ARGTYPE_INT | ARGTYPE_HIDDEN, "0", "15", nullptr }, { "fields", &opt_fields, "Name and order of input fields, separated by '+'", - NULL, ARGTYPE_STRING, ARG_NOMINMAX + NULL, ARGTYPE_STRING, ARG_NOMINMAX, nullptr }, ARG_TERMINATOR }; @@ -2108,4 +2108,6 @@ ff_vecs_t unicsv_vecs = { NULL, unicsv_args, CET_CHARSET_ASCII, 0 /* can be changed with -c ... */ + , NULL_POS_OPS, + nullptr }; diff --git a/v900.cc b/v900.cc index 888387d72..1bfe78cca 100644 --- a/v900.cc +++ b/v900.cc @@ -386,5 +386,6 @@ ff_vecs_t v900_vecs = { NULL, NULL, /* args */ CET_CHARSET_UTF8, 1, /* Could be US-ASCII, since we only read "0-9,A-Z\n\r" */ - {NULL,NULL,NULL,NULL,NULL,NULL} + {NULL,NULL,NULL,NULL,NULL,NULL}, + nullptr }; diff --git a/validate.cc b/validate.cc index af7b1225a..9fb47ed5c 100644 --- a/validate.cc +++ b/validate.cc @@ -40,17 +40,17 @@ static arglist_t validate_args[] = { { "checkempty", &opt_checkempty, "Check for empty input", - "0", ARGTYPE_BOOL, ARG_NOMINMAX + "0", ARGTYPE_BOOL, ARG_NOMINMAX, nullptr } , { "debug", &opt_debug, "Output debug messages instead of possibly issuing a fatal error", - "0", ARGTYPE_BOOL, ARG_NOMINMAX + "0", ARGTYPE_BOOL, ARG_NOMINMAX, nullptr } , ARG_TERMINATOR }; -static void validate_head(const route_head* header) +static void validate_head(const route_head*) { head_ct += 1; segment_ct_start = point_ct; @@ -67,13 +67,13 @@ static void validate_head_trl(const route_head* header) } } -static void validate_point(const Waypoint* waypointp) +static void validate_point(const Waypoint*) { point_ct += 1; } static void -validate_process(void) +validate_process() { debug = *opt_debug == '1'; diff --git a/vcf.cc b/vcf.cc index aecef6940..7f3814904 100644 --- a/vcf.cc +++ b/vcf.cc @@ -35,7 +35,7 @@ static arglist_t vcf_args[] = { { "encrypt", &vcf_encrypt, - "Encrypt hints using ROT13", NULL, ARGTYPE_BOOL, ARG_NOMINMAX + "Encrypt hints using ROT13", NULL, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr }, ARG_TERMINATOR }; @@ -151,4 +151,6 @@ ff_vecs_t vcf_vecs = { NULL, vcf_args, CET_CHARSET_ASCII, 0 /* CET-REVIEW */ + , NULL_POS_OPS, + nullptr }; diff --git a/vidaone.cc b/vidaone.cc index 72d7756bf..d65c6925c 100644 --- a/vidaone.cc +++ b/vidaone.cc @@ -47,7 +47,7 @@ arglist_t vidaone_args[] = { { VIDAONE_VER, &vidaone_opt_ver, "Version of VidaOne file to read or write (1 or 2)", - "1", ARGTYPE_INT, "1", "2" + "1", ARGTYPE_INT, "1", "2", nullptr }, ARG_TERMINATOR }; @@ -148,6 +148,8 @@ ff_vecs_t vidaone_vecs = { NULL, vidaone_args, CET_CHARSET_UTF8, 1 + , NULL_POS_OPS, + nullptr }; /**************************************************************************/ diff --git a/vitosmt.cc b/vitosmt.cc index 61ea029d6..9ac486949 100644 --- a/vitosmt.cc +++ b/vitosmt.cc @@ -368,4 +368,6 @@ ff_vecs_t vitosmt_vecs = { NULL, NULL, CET_CHARSET_UTF8, 1 /* do nothing | CET-REVIEW */ + , NULL_POS_OPS, + nullptr }; diff --git a/vitovtt.cc b/vitovtt.cc index 2a3b5ce96..cf4cd705e 100644 --- a/vitovtt.cc +++ b/vitovtt.cc @@ -133,4 +133,6 @@ ff_vecs_t vitovtt_vecs = { NULL, NULL, CET_CHARSET_UTF8, 1 /* do nothing | CET-REVIEW */ + , NULL_POS_OPS, + nullptr }; diff --git a/vpl.cc b/vpl.cc index 3db5cb9f1..5ad963111 100644 --- a/vpl.cc +++ b/vpl.cc @@ -156,7 +156,7 @@ vpl_read(void) } static void -vpl_wr_init(const QString& fname) +vpl_wr_init(const QString&) { fatal("Writing file of type %s is not support\n", MYNAME); } @@ -232,5 +232,7 @@ ff_vecs_t vpl_vecs = { vpl_args, CET_CHARSET_ASCII, /* ascii is the expected character set */ 1 /* fixed, can't be changed through command line parameter */ + , NULL_POS_OPS, + nullptr }; /**************************************************************************/ diff --git a/waypt.cc b/waypt.cc index 86a2f12a3..3c17fa94e 100644 --- a/waypt.cc +++ b/waypt.cc @@ -43,13 +43,13 @@ static short_handle mkshort_handle; geocache_data Waypoint::empty_gc_data; static global_trait traits; -const global_trait* get_traits(void) +const global_trait* get_traits() { return &traits; } void -waypt_init(void) +waypt_init() { mkshort_handle = mkshort_new_handle(); #if NEWQ @@ -154,7 +154,7 @@ waypt_del(Waypoint* wpt) } unsigned int -waypt_count(void) +waypt_count() { #if NEWQ return waypt_list.size(); @@ -688,7 +688,7 @@ Waypoint::Waypoint(const Waypoint& other) : // note: extra_data is not deep copied. } -Waypoint& Waypoint::operator=(const Waypoint& other) +Waypoint& Waypoint::operator=(const Waypoint& /* other */) { // the default assignment operator is not appropriate as we do deep copy of some members, // and we haven't bothered to write an appropriate one. diff --git a/wbt-200.cc b/wbt-200.cc index 19ea0f9ed..b0e519af1 100644 --- a/wbt-200.cc +++ b/wbt-200.cc @@ -1093,7 +1093,7 @@ static void data_read(void) static arglist_t wbt_sargs[] = { { "erase", &erase, "Erase device data after download", - "0", ARGTYPE_BOOL, ARG_NOMINMAX + "0", ARGTYPE_BOOL, ARG_NOMINMAX, nullptr }, ARG_TERMINATOR }; @@ -1110,6 +1110,8 @@ ff_vecs_t wbt_svecs = { NULL, wbt_sargs, CET_CHARSET_UTF8, 1 /* master process: don't convert anything | CET-REVIEW */ + , NULL_POS_OPS, + nullptr }; /* used for wbt-bin /and/ wbt-tk1 */ @@ -1130,4 +1132,6 @@ ff_vecs_t wbt_fvecs = { NULL, wbt_fargs, CET_CHARSET_UTF8, 1 /* master process: don't convert anything | CET-REVIEW */ + , NULL_POS_OPS, + nullptr }; diff --git a/wfff_xml.cc b/wfff_xml.cc index d010c0e15..586f4a80c 100644 --- a/wfff_xml.cc +++ b/wfff_xml.cc @@ -33,22 +33,22 @@ static arglist_t wfff_xml_args[] = { { "aicicon", &aicicon, "Infrastructure closed icon name", - "Red Square", ARGTYPE_STRING + "Red Square", ARGTYPE_STRING, ARG_NOMINMAX, NULL }, { "aioicon", &aioicon, "Infrastructure open icon name", - "Green Square", ARGTYPE_STRING + "Green Square", ARGTYPE_STRING, ARG_NOMINMAX, NULL }, { "ahcicon", &ahcicon, "Ad-hoc closed icon name", - "Red Diamond", ARGTYPE_STRING + "Red Diamond", ARGTYPE_STRING, ARG_NOMINMAX, NULL }, { "ahoicon", &ahoicon, "Ad-hoc open icon name", - "Green Diamond", ARGTYPE_STRING + "Green Diamond", ARGTYPE_STRING, ARG_NOMINMAX, NULL }, - {"snmac", &snmac, "Shortname is MAC address", NULL, ARGTYPE_BOOL }, - {0, 0, 0, 0, 0} + {"snmac", &snmac, "Shortname is MAC address", NULL, ARGTYPE_BOOL, ARG_NOMINMAX, NULL }, + ARG_TERMINATOR }; #define xfreez(p) { if (p) xfree(p); p=0; } @@ -148,7 +148,7 @@ void wfff_lon(const QString& args, const QXmlStreamAttributes*) { /* End of AP Block, set waypoint and add */ static long tosscount=0; -void wfff_e(xg_string args, const QXmlStreamAttributes*) +void wfff_e(xg_string, const QXmlStreamAttributes*) { Waypoint* wpt_tmp =0; char desc[255] ="\0"; @@ -235,5 +235,8 @@ ff_vecs_t wfff_xml_vecs = { wfff_xml_read, 0, 0, - wfff_xml_args + wfff_xml_args, + CET_CHARSET_UTF8, 0, + NULL_POS_OPS, + nullptr }; diff --git a/wintec_tes.cc b/wintec_tes.cc index 8b6ffe021..76fb3d049 100644 --- a/wintec_tes.cc +++ b/wintec_tes.cc @@ -115,4 +115,6 @@ ff_vecs_t wintec_tes_vecs = { wintec_tes_args, CET_CHARSET_ASCII, 0 /* ascii is the expected character set */ /* not fixed, can be changed through command line parameter */ + , NULL_POS_OPS, + nullptr }; diff --git a/xcsv.cc b/xcsv.cc index 058a3cc97..5c188c157 100644 --- a/xcsv.cc +++ b/xcsv.cc @@ -53,36 +53,36 @@ static arglist_t xcsv_args[] = { { "style", &styleopt, "Full path to XCSV style file", NULL, - ARGTYPE_FILE | ARGTYPE_REQUIRED, ARG_NOMINMAX + ARGTYPE_FILE | ARGTYPE_REQUIRED, ARG_NOMINMAX, nullptr }, { "snlen", &snlenopt, "Max synthesized shortname length", NULL, - ARGTYPE_INT, "1", NULL + ARGTYPE_INT, "1", NULL, nullptr }, { "snwhite", &snwhiteopt, "Allow whitespace synth. shortnames", - NULL, ARGTYPE_BOOL, ARG_NOMINMAX + NULL, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr }, { "snupper", &snupperopt, "UPPERCASE synth. shortnames", - NULL, ARGTYPE_BOOL, ARG_NOMINMAX + NULL, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr }, { "snunique", &snuniqueopt, "Make synth. shortnames unique", - NULL, ARGTYPE_BOOL, ARG_NOMINMAX + NULL, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr }, { "urlbase", &xcsv_urlbase, "Basename prepended to URL on output", - NULL, ARGTYPE_STRING, ARG_NOMINMAX + NULL, ARGTYPE_STRING, ARG_NOMINMAX, nullptr }, { "prefer_shortnames", &prefer_shortnames, "Use shortname instead of description", - NULL, ARGTYPE_BOOL, ARG_NOMINMAX + NULL, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr }, { "datum", &opt_datum, "GPS datum (def. WGS 84)", - "WGS 84", ARGTYPE_STRING, ARG_NOMINMAX + "WGS 84", ARGTYPE_STRING, ARG_NOMINMAX, nullptr }, ARG_TERMINATOR }; @@ -706,7 +706,8 @@ ff_vecs_t xcsv_vecs = { NULL, xcsv_args, CET_CHARSET_ASCII, 0, /* CET-REVIEW */ - { NULL, NULL, NULL, xcsv_wr_position_init, xcsv_wr_position, xcsv_wr_position_deinit } + { NULL, NULL, NULL, xcsv_wr_position_init, xcsv_wr_position, xcsv_wr_position_deinit }, + nullptr }; #else diff --git a/xol.cc b/xol.cc index 68afca685..ccdebd052 100644 --- a/xol.cc +++ b/xol.cc @@ -54,7 +54,7 @@ static xg_tag_mapping xol_map[] = { { xol_waypt, cb_start, XOL "/shapes/shape/*points/point" }, { NULL, (xg_cb_type)0, NULL} }; -static void xol_overlay(xg_string args, const QXmlStreamAttributes* attrv) { +static void xol_overlay(xg_string, const QXmlStreamAttributes* attrv) { if (attrv->hasAttribute("version")) { if (attrv->value("version") != "1.0") { fatal(MYNAME ": Unsupported version %s.\n", @@ -63,7 +63,7 @@ static void xol_overlay(xg_string args, const QXmlStreamAttributes* attrv) { } } -static void xol_shape(xg_string args, const QXmlStreamAttributes* attrv) { +static void xol_shape(xg_string, const QXmlStreamAttributes* attrv) { if (attrv->hasAttribute("type")) { if (attrv->value("type") == "waypoint") { wpt = new Waypoint; @@ -101,7 +101,7 @@ static void xol_shape(xg_string args, const QXmlStreamAttributes* attrv) { } } -static void xol_shape_end(xg_string args, const QXmlStreamAttributes*) { +static void xol_shape_end(xg_string, const QXmlStreamAttributes*) { if (wpt) { if (trk) { track_add_wpt(trk, wpt); @@ -117,7 +117,7 @@ static void xol_shape_end(xg_string args, const QXmlStreamAttributes*) { } } -static void xol_waypt(xg_string args, const QXmlStreamAttributes* attrv) { +static void xol_waypt(xg_string, const QXmlStreamAttributes* attrv) { int x = 0, y = 0; if (attrv->hasAttribute("y")) { @@ -138,9 +138,9 @@ static void xol_rd_init(const QString& fname) { xml_init(fname, xol_map, NULL); } -static void xol_read(void) { xml_read(); } +static void xol_read() { xml_read(); } -static void xol_rd_deinit(void) { xml_deinit(); } +static void xol_rd_deinit() { xml_deinit(); } /* writer */ @@ -175,7 +175,7 @@ static void xol_wr_init(const QString& fname) { setshort_defname(short_h, "Waypoint"); } -static void xol_wr_deinit(void) { +static void xol_wr_deinit() { mkshort_del_handle(&short_h); writer->writeEndDocument(); delete writer; @@ -220,7 +220,7 @@ static void xol_waypt_disp_cb(const Waypoint* wpt) { writer->writeEndElement(); // shape } -static void xol_track_hdr_disp_cb(const route_head* trk) { +static void xol_track_hdr_disp_cb(const route_head*) { writer->writeStartElement("shape"); writer->writeAttribute("type", "polyline"); writer->writeAttribute("lineSize", "3"); @@ -229,7 +229,7 @@ static void xol_track_hdr_disp_cb(const route_head* trk) { writer->writeStartElement("waypoints"); } -static void xol_track_tlr_disp_cb(const route_head* trk) { +static void xol_track_tlr_disp_cb(const route_head*) { writer->writeEndElement(); // waypoints writer->writeEndElement(); // shape } @@ -259,7 +259,7 @@ static void xol_trkpt_disp_cb(const Waypoint* wpt) { writer->writeEndElement(); // shape } -static void xol_write(void) { +static void xol_write() { double x, y; waypt_disp_all(xol_waypt_bound_calc); @@ -308,4 +308,6 @@ ff_vecs_t xol_vecs = {ff_type_file, NULL, xol_args, CET_CHARSET_UTF8, - 0}; + 0 , NULL_POS_OPS, + nullptr +}; diff --git a/yahoo.cc b/yahoo.cc index b7cda7311..30e447e66 100644 --- a/yahoo.cc +++ b/yahoo.cc @@ -33,7 +33,7 @@ arglist_t yahoo_args[] = { { "addrsep", &as, "String to separate concatenated address fields (default=\", \")", - ", ", ARGTYPE_STRING, ARG_NOMINMAX + ", ", ARGTYPE_STRING, ARG_NOMINMAX, nullptr }, ARG_TERMINATOR }; @@ -61,29 +61,29 @@ yahoo_rd_init(const QString& fname) } static void -yahoo_read(void) +yahoo_read() { xml_read(); } static void -yahoo_rd_deinit(void) +yahoo_rd_deinit() { xml_deinit(); } static void -yahoo_wr_init(const QString& fname) +yahoo_wr_init(const QString&) { fatal("Writing file of type %s is not supported\n", MYNAME); } -void wpt_s(xg_string args, const QXmlStreamAttributes*) +void wpt_s(xg_string, const QXmlStreamAttributes*) { wpt_tmp = new Waypoint; } -void wpt_e(xg_string args, const QXmlStreamAttributes*) +void wpt_e(xg_string, const QXmlStreamAttributes*) { waypt_add(wpt_tmp); wpt_tmp = NULL; @@ -119,4 +119,6 @@ ff_vecs_t yahoo_vecs = { NULL, yahoo_args, CET_CHARSET_ASCII, 0 /* CET-REVIEW */ + , NULL_POS_OPS, + nullptr }; -- 2.30.2